calico
calico
CC#
Created by calico on 3/25/2024 in #help
[SOLVED] (WPF) Textblock inputs not saving on Navigation to new page?
(SOLVED - Solution Below) I'm currently having trouble with page navigation in WPF, I currently have a MainWindow with a sidebar, and a Frame in the middle of the window to display new pages. The sidebar navigation seems to work fine, but the issue is whenever I navigate to a new page and back, it doesn't save any of the information that was filled out in any of the textblocks. C#
public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); MainFrame.Navigate(new Uri("P1Home.xaml", UriKind.RelativeOrAbsolute)); } private void BtnHomePage_Click(object sender, RoutedEventArgs e) { MainFrame.Navigate(new Uri("P1Home.xaml", UriKind.RelativeOrAbsolute)); } private void BtnDependencies_Click(object sender, RoutedEventArgs e) { MainFrame.Navigate(new Uri("P4Dependencies.xaml", UriKind.RelativeOrAbsolute)); }
I have tried using KeepAlive=true for each page with no luck, I was thinking the issue was that when each button is pressed I am "recreating" the page instead of moving back to it, so it is erasing the inputs(?) (If it helps, I am using .NET 6.0) Thanks in advance, (Sorry if the question is a bit basic, I am still learning a lot)
16 replies