title: How to clear navigation history in a frame when using the window Current page as a view model Property for a window View Model
body: <p>I am making a WPF application for sales.
  What I want to do is to navigate to diffrent views while choosing whether I keep the navigation history (in case I want to keep a temporary instance of a transaction) or remove one or all history of navigation (in case I want to validate all temporary transactions)
  for example, I have a page transaction
  there is the case where I want to keep other instances of that page open temperarly or remove all instances if I am done with one or all transaction.
  I made a mainwindow that contain a frame .
  I want to navigate to a diffrent page inside the frame when a button is clicked while also choosing to keep or remove the navigation history.
  What I did so far was implement a window view model class and create a property (PageView) that is a enum that I can convert to the page view I want to show.</p>
  <p>The pageview enum</p>
  <pre><code>public enum PageView
  {
      Main=0,
      SecondPage=1
  }
  </code></pre>
  <p>The converter from property PageView to the page I want to show</p>
  <pre><code>public class PageConverter : BaseCoverter&lt;PageConverter&gt;
  {
      public override object Convert(object value, Type targetType, object parameter, CultureInfo culture)
      {
          switch ((PageView)value)
          {
              
              default: Debugger.Break();
                  return null;
              case PageView.Main:
                  return new MainPage();
              case PageView.SecondPage:
                  return new SecondoryPage();
          }
      }
  
      public override object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
      {
          throw new NotImplementedException();
      }
  }
  </code></pre>
  <p>}</p>
  <p>Main window view model</p>
  <pre><code>class WindowVM:BaseViewModel
  {
      private Window VWindow;
      private PageView _pageView= PageView.Main;
      public WindowVM(Window window)
      {
          VWindow = window; 
          SwitchView = new RelayCommand(_SwitchView, _CheckButton);
      }       
      public PageView CurrentPage
      {
          set
          {
              _pageView = value;
              OnPropertyChanged(); 
          }
          get { return _pageView; ; }
      }
      public ICommand SwitchView { get; set; }
  
      private void _SwitchView()
      {
          ((WindowVM)((MainWindow)Application.Current.MainWindow).DataContext).CurrentPage = PageView.SecondPage;
      }
  
      private bool _CheckButton(object parameter)
      {
          return true;
      }
  }
  </code></pre>
  <p>What I have right now is a frame that create a new page each time the command SwitchView is used.
  What I want is to choose whether I want to be able to clear the history of the pages I navigated if i wanted to.</p>
  <p>I found <a href="https://stackoverflow.com/questions/2285122/prevent-wpf-frame-from-storing-history-in-the-stack">this solution</a> but I don't want to use code behind to do that.
  I also found <a href="https://stackoverflow.com/questions/8585519/how-to-clear-whole-navigation-history-hosted-by-the-wpf-frame-control">this solution</a> but I really didn't know how to implement it.</p>