title: C#, Windows Phone 7, Using if-else statement to check which page is displayed
body: <p>Now I'm developing a Windows Phone 7 app, my app has three buttons located at the applicaton bar. Here is the event handler for these three buttons:</p>
  
  <pre><code>    //app bar page navigation
      private void ApplicationBarIconButton_Click1(object sender, EventArgs e)
      {
          if(//check if the current displayed page is mainpage)
          {
              //do nothing
          }
          else
          {
              NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.RelativeOrAbsolute));
          }
      }
  
      private void ApplicationBarIconButton_Click2(object sender, EventArgs e)
      {
          NavigationService.Navigate(new Uri("/Audios.xaml", UriKind.RelativeOrAbsolute));
      }
  
      private void ApplicationBarIconButton_Click3(object sender, EventArgs e)
      {
          NavigationService.Navigate(new Uri("/Statistics.xaml", UriKind.RelativeOrAbsolute));
      }
  </code></pre>
  
  <p>The button navigation works well except the first one (<code>Button_Click1</code>) because when I first access the main page and click the first button the app will automatically go back to app list. </p>
  
  <p>So I want to use if-else statement to check which page is currently displayed and then decide whether to navigate or stay in the current page.</p>