The program needs to achieve multi-page switching, I used ContentControl and Page. However, in the test, it was found that when switching from Page1 to Page2 and then back to Page1, the data inside will not be saved.
Code:
In MainWindow.xaml
:
<ContentControl x:Name="ShowPage" Height="450" Width="770"/>
In MainWindow.xaml.cs
:
private void OpenHomePage(object sender, RoutedEventArgs e) //A button event
{
Pages.Home Home = new Pages.Home();
ShowPage.Content = new Frame() { Content = Home };
}
E.g: I enter "123" in the text box in Page1, I switch to Page2 and then go back to Page1, the content of the text box will disappear, and the "123" I entered is not saved.
Is there any way to save the entered data?