This is a migrated thread and some comments may be shown as answers.

hiding/showing pages when use switch pages

2 Answers 352 Views
NavigationView (Hamburger Menu)
This is a migrated thread and some comments may be shown as answers.
zigzag
Top achievements
Rank 1
zigzag asked on 02 Oct 2019, 05:59 AM

On my development, each navigationView Item will display a page which is defined by an User control. When user click items on left-hand side, corresponding page is displayed on right-hand side.

Now considering following case:

  • User is working on a page (let's call it GRID page) which shows a few grids and some input editors. User rearranges columns of a grid; user selects a few rows of a grid; user inputs some texts on editor
  • User clicks another NavigationView item to look for some information on another page;
  • User switches back to GRID page, and he will discover that all the changes he just made are gone. Every thing goes back to initial state.

Debugging told me that the user control of GRID page is re-created whe user switched back to GRID page

My questions:

  1. Instead of destroying/creating pages, is that a way to hide/show pages when use switch pages?
  2. If this is impossible, how can I perserve the status of a page so that user can go back and continue working on it.

Thanks.

2 Answers, 1 is accepted

Sort by
1
Accepted
Dimitar Dinev
Telerik team
answered on 03 Oct 2019, 03:54 PM

Hi Hao,

Thank you for the detailed explanation.

What you have observed is the expected behavior, since when the content is changed the corresponding controls are detached from the visual tree, which makes them lose their state.

There is a way to hide/show the pages when you switch between them and I've demonstrated one approach in a sample project. As an alternative, you can also take a look at the RadPersistenceFramework which allows you to save the visual state of your application.

Attached, you can find the sample project. Please, review it and let me know if it delivered the desired result.

Regards,
Dimitar Dinev
Progress Telerik

Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
zigzag
Top achievements
Rank 1
answered on 07 Oct 2019, 10:49 PM
That works. thanks.
Tags
NavigationView (Hamburger Menu)
Asked by
zigzag
Top achievements
Rank 1
Answers by
Dimitar Dinev
Telerik team
zigzag
Top achievements
Rank 1
Share this question
or