小编use*_*145的帖子

如何在Windows Phone 8中覆盖窗口后退按钮?

当我从我的应用程序点击时,我需要将窗口后退按钮.我尝试了下面的方法,但它在Windows Phone 8中不起作用?

方法1)

protected override void OnBackKeyPress(System.ComponentModel.CancelEventArgs e)

            {

           e.Cancel = true;

           var result = MessageBox.Show("Do you want to exit?", "Attention!",
                                      MessageBoxButton.OKCancel);

        if (result == MessageBoxResult.OK)
        {
           // base.OnBackKeyPress(e);
            return;
        }
        e.Cancel = true;
    }
Run Code Online (Sandbox Code Playgroud)

方法2)

a)在xaml标题中写道

BackKeyPress="MyBackKeyPress"
Run Code Online (Sandbox Code Playgroud)

b)在构造函数中初始化它

 BackKeyPress += OnBackKeyPress;
Run Code Online (Sandbox Code Playgroud)

c)并调用此方法

   private void MyBackKeyPress(object sender, System.ComponentModel.CancelEventArgs e)
    {
        e.Cancel = true; //tell system you have handled it
        //you c
    }
Run Code Online (Sandbox Code Playgroud)

这两种方法都不起作用.当我点击后退按钮时,应用程序被破坏,无法控制后门按钮.有帮助吗?

c# windows-phone-7 windows-phone-8

3
推荐指数
1
解决办法
2万
查看次数

如何在Windows Phone 8中使用对象导航?

我需要使用Object而不是String从一个xaml页面导航到另一个页面.

目前的代码是:

  private void Border_ManipulationStarted(object sender,    System.Windows.Input.ManipulationStartedEventArgs e)
{
     string uri = "/PhonePageOne.xaml?Text=";
     uri += txtBox.Text;
     NavigationService.Navigate(new Uri(uri, UriKind.Relative));
}
Run Code Online (Sandbox Code Playgroud)

我不想在网址中传递文字,我需要传递一个对象,而不是像下面那样,并以任何方式做到这一点?

Person p = new person();
uri+=p
Run Code Online (Sandbox Code Playgroud)

c# windows-phone-7 windows-phone-8

1
推荐指数
1
解决办法
5130
查看次数

标签 统计

c# ×2

windows-phone-7 ×2

windows-phone-8 ×2