0

如何从 Windows Phone 7 中的 EventArgs e 按钮(应用程序栏上的按钮)按 RoutedEventArgs e 按钮(页面中的按钮)

    private void button3_Click(object sender, EventArgs e)
    {
        button0_Click(sender, e);
    }

    private void button0_Click(object sender, RoutedEventArgs e)
    {

    }

当我使用上面的代码时,它给了我

无法从“System.EventArgs”转换为“System.Windows.RoutedEventArgs”

请帮忙

短信代码:

    SmsComposeTask SCT = new SmsComposeTask();

    PhoneApplicationService PAS = PhoneApplicationService.Current;

    public string SMSNO;

    protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
    {
        object sample;
        if (PAS.State.TryGetValue("numbertext", out sample))
            SMSNO = sample as string;
        if (PAS.State.TryGetValue("messagetext", out sample))
            txtOutput.Text = sample as string;
        base.OnNavigatedTo(e);
    }

    private void button2_Click(object sender, RoutedEventArgs e)
    {
        if (txtOutput.Text != "")
        {
            SCT.To = SMSNO;
            SCT.Body = txtOutput.Text;
            SCT.Show();
        }
        else
        {
            MessageBox.Show("Output is Empty to send SMS.", "Wait!", MessageBoxButton.OK);
        }
    }

    protected override void OnNavigatedFrom(System.Windows.Navigation.NavigationEventArgs e)
    {
        PAS.State["numbertext"] = SMSNO;
        PAS.State["messagetext"] = txtOutput.Text;
        base.OnNavigatedFrom(e);
    }
4

1 回答 1

1

如果你不使用button0_Click里面的参数,你可以调用button0_Click(sender, null); (原因是来自应用程序栏的事件不会冒泡,这就是它们没有 RoutedEventArg 参数的原因)

于 2013-09-17T22:50:52.500 回答