2

Is there any posibility to keep content of page after navigate of it. For example I have Window with frame and few buttons and every button navigate on some page.

frame.Navigate(new Page1()); //every button for different page 

Now one page for example have some textblock and button. If a click on button text of textblock change. When I go to some other page and come back to that page the textblock.Text will not be saved, it will back to default value? How to keep it?

I know in wp 8.1 you can do it with this line of code in constructor:

this.NavigationCacheMode = NavigationCacheMode.Required; 

but, I can't find how to the the same in WPF.

3 Answers 3

1

The idea behind it is very simple. The data is not being stored in the page since when you navigate to the page, a new instance of the page is being created.

You can do so by maintaining a static instance of the page. ie the page is created only the first time the application is run. The next time you load the page, the state will be maintained.

Sign up to request clarification or add additional context in comments.

Comments

0

You could use an overloaded version of Frame.Navigate():

public bool Navigate( object content, object extraData ) 

In the extraData, you can pass a param to the page you want to navigate to, usually a string. And the info you place in this string can be used by the loaded page to initialize itself with the desired data.

Comments

0

You can use KeepAlive = true; property inside each page that you want cache in back stack.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.