Frage

In my WPF appln, I have a Dialog window with couple of buttons and For each button click I can Navigate the pages in the MainWindow by "Frame.Navigate(_page);" .But from the page I am unable to go back my previous dialog window. I used "Frame.NavigationService.GoBack();". But it is not going back to the Dialog window.It is not moving out from the MainWindow. Can Anyone please resolve my problem?

War es hilfreich?

Lösung

Go back can happen only when navigationService.CanGoBack is true. Ensure the value of this property. You can go back if navigation is done earlier. This actually functions similar to undo redo. Also I verified with following snippet that works fine for me,

NavigationService service;
public MainWindow()
{
    InitializeComponent();
    service = mainframe.NavigationService;
    service.Navigate("Page2.xaml");
}

private void Button_Click_1(object sender, RoutedEventArgs e)
{
    if (service.CanGoBack)
        service.GoBack();
}
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top