title: Working with Windows Phone 8.1 Back Key Press Event
body: <p>I'm working on my Windows Phone 8.1 app. I want to show message when user press back key . I know the  codes but something is going wrong. Visual Studio showing me redlines under MessageBox , MessageBoxResult.</p>
  
  <p>How can i show message in Windows Phone 8.1 ? I think it has changed after WP7 OS. </p>
  
  <p>Here the example of my codes.</p>
  
  <pre><code>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);
      }
  </code></pre>