【发布时间】:2014-07-09 12:20:15
【问题描述】:
我正在开发我的 Windows Phone 8.1 应用程序。我想在用户按下返回键时显示消息。我知道代码,但出了点问题。 Visual Studio 在 MessageBox 、 MessageBoxResult 下显示红线。
如何在 Windows Phone 8.1 中显示消息?我认为它在 WP7 OS 之后发生了变化。
这里是我的代码示例。
public MainPage()
{
this.InitializeComponent();
progRing.IsActive = true;
Window.Current.SizeChanged += Current_SizeChanged;
Windows.Phone.UI.Input.HardwareButtons.BackPressed += HardwareButtons_BackPressed;
this.NavigationCacheMode = NavigationCacheMode.Required;
}
protected override void OnNavigatedTo(NavigationEventArgs e)
{
}
private void HardwareButtons_BackPressed(object sender, Windows.Phone.UI.Input.BackPressedEventArgs e)
{
}
protected override void OnBackKeyPress(System.ComponentModel.CancelEventArgs e)
{
string caption = "Stop music and exit?";
string message = "If you want to continue listen music while doing other stuff, please use Home key instead of Back key. Do you still want to exit?";
e.Cancel = MessageBoxResult.Cancel == MessageBox.Show(message, caption, MessageBoxButton.OKCancel);
base.OnBackKeyPress(e);
}
【问题讨论】:
-
那些红线是什么意思?也许您的目标是 WP8.1 RT 和 this question will help。
标签: c# windows-phone-8 messagebox