calico
calico
CC#
Created by calico on 3/25/2024 in #help
[SOLVED] (WPF) Textblock inputs not saving on Navigation to new page?
Similar to the solution that @SpReeD had provided above, thank you again for your help.(and sorry again for the ping lol)
16 replies
CC#
Created by calico on 3/25/2024 in #help
[SOLVED] (WPF) Textblock inputs not saving on Navigation to new page?
Sorry again, just thought I would post here as I've been able to fix the issue for anyone having a similar problem: Essentially I went and created a static instance of each page at runtime, so instead of the NavigationService creating a new instance of each window when navigating with my sidebar, it would simply load the static instance of each page that would save each time I navigated. Example below: App.xaml.cs
// Defining static instances of each page
public static class PageInstances
{
public static PageOne PageOneInstance { get; } = new PageOne();
public static PageTwo PageTwoInstance { get; } = new PageTwo();
// Any other Pages here
}
// Defining static instances of each page
public static class PageInstances
{
public static PageOne PageOneInstance { get; } = new PageOne();
public static PageTwo PageTwoInstance { get; } = new PageTwo();
// Any other Pages here
}
MainWindow.xaml.cs
// Navigation logic via buttons (sidebar)
private void BtnPageOne_Click(object sender, RoutedEventArgs e)
{
MyFrame.NavigationService.Navigate(PageInstances.PageOneInstance);
}

private void BtnPageTwo_Click(object sender, RoutedEventArgs e)
{
MyFrame.NavigationService.Navigate(PageInstances.PageTwoInstance);
}
// Navigation logic via buttons (sidebar)
private void BtnPageOne_Click(object sender, RoutedEventArgs e)
{
MyFrame.NavigationService.Navigate(PageInstances.PageOneInstance);
}

private void BtnPageTwo_Click(object sender, RoutedEventArgs e)
{
MyFrame.NavigationService.Navigate(PageInstances.PageTwoInstance);
}
16 replies
CC#
Created by calico on 3/25/2024 in #help
[SOLVED] (WPF) Textblock inputs not saving on Navigation to new page?
Ah okay, that makes sense. I'll try and implement that. Thanks so much for the help, I appreciate it 🙂
16 replies
CC#
Created by calico on 3/25/2024 in #help
[SOLVED] (WPF) Textblock inputs not saving on Navigation to new page?
I suppose I could add a check in each button to check if the window is already open or not? (Not sure of that process, but just an idea)
16 replies
CC#
Created by calico on 3/25/2024 in #help
[SOLVED] (WPF) Textblock inputs not saving on Navigation to new page?
It seems the way I have the buttons set up, it keeps creating a new instance of each page everytime I click it, instead of navigating back to it.
16 replies
CC#
Created by calico on 3/25/2024 in #help
[SOLVED] (WPF) Textblock inputs not saving on Navigation to new page?
Sorry, but a new discovery: If I leave the navigationUI visible, and I click the back or forth button, it seems to keep the information in the textboxes. But when I navigate by clicking on the buttons I have in my sidebar (shown in the code above) it clears all the values..
16 replies
CC#
Created by calico on 3/25/2024 in #help
[SOLVED] (WPF) Textblock inputs not saving on Navigation to new page?
To my knowledge, if I wanted to store it for when it reopens, I could use .settings, but I don't need that functionality
16 replies
CC#
Created by calico on 3/25/2024 in #help
[SOLVED] (WPF) Textblock inputs not saving on Navigation to new page?
For storing the information, would like to store it only in runtime or on disk, so it'll be loaded the next time the application starts?
I just need to store it for the duration of the runtime, no need to save it for when the application reopens
16 replies
CC#
Created by calico on 3/25/2024 in #help
[SOLVED] (WPF) Textblock inputs not saving on Navigation to new page?
Sorry for the long response, just making sure I'm understanding right
16 replies
CC#
Created by calico on 3/25/2024 in #help
[SOLVED] (WPF) Textblock inputs not saving on Navigation to new page?
Ohh okay, yes I was looking into MVVM but wasn't sure if it was what I needed. As far as I understand, by using MVVM I will basically be loading the page into the frame and any other page "on top" of it so it won't erase the data thats already entered(?) For some background on the program, its just supposed to be a simple interface that will take the user inputs to generate and structure a .xml file to be opened, so I was also guessing I would need to store the entries as strings anyways for that purpose?
16 replies