从另一个按钮单击调用按钮单击

时间:2013-09-17 22:48:11

标签: windows-phone-7

如何从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);
    }

1 个答案:

答案 0 :(得分:1)

如果你不使用button0_Click里面的参数,你只需要调用button0_Click(sender,null); (原因是应用程序栏中的事件没有冒泡,这就是他们没有RoutedEventArg参数的原因)