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.
The pageview enum
public enum PageView
{
    Main=0,
    SecondPage=1
}
The converter from property PageView to the page I want to show
public class PageConverter : BaseCoverter<PageConverter>
{
    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();
    }
}
}
Main window view model
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;
    }
}
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.
I found this solution but I don't want to use code behind to do that. I also found this solution but I really didn't know how to implement it.