I write uwp application. I use splitview as a menu for navigation (page transitions). I don’t want to copy the splitview code on each village because of the memory. I found a way to make it to all the pages at once - I created a UserControl (a separate xaml file). There put splitview with code. On the pages where I need it, I write in the xaml code -
<SplitView x:Name="Menu"> <local:MenuX/> </SplitView> Everything works fine, but the problem is that when I move from page to page, the new page simply overlaps the old one. That is, the memory of the previous page and all its elements is not released. Here is the part of the code that goes to another page.
private void Home_SelectionChanged (object sender, SelectionChangedEventArgs e) { if (Home.SelectedIndex == 0) myFrame.Navigate(typeof(MainPage)); } Actually on the page with the splitview itself I create a frame
<Frame x:Name="myFrame"/> Tried to use
private void Home_SelectionChanged (object sender, SelectionChangedEventArgs e) { if (Home.SelectedIndex == 0) Frame.Navigate(typeof(MainPage)); ///Frame вместо myFrame } But it gives an error that a non-static method requires an object reference. Maybe someone knows how to solve this problem and free up memory, or somehow make a common splitview, or how to get a link to the object (as I understand it on the page itself).