当我从我的应用程序点击时,我需要将窗口后退按钮.我尝试了下面的方法,但它在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)
这两种方法都不起作用.当我点击后退按钮时,应用程序被破坏,无法控制后门按钮.有帮助吗?
我需要使用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)