windows phone 7 - Handling the OnNavigatedFrom / OnNavigatedTo events in the ViewModel -


When I navigate from the page or to save or restore the position of the page, Trying to remove the path

The first attempt I tried was to add an event talk comedic behavior on the page, but the event (Onalvisent and Onvigated) was declared protected and does not appear to bind eventual events.

Next I thought that I would try to use the code behind the code to see a message from ViewModel using Messenger Class:

  Protected Override Zero OnNavigatedFrom (System.Windows.Navigation.NavigationEventWorks e) {Messenger.Default.Send & lt; PhoneApplicationPage & gt; (this); Base.OnNavigatedFrom (E); } To update protected override zero (System .windows.navigation.NavigationEventErgase E) {Messenger. Default. Send & lt; Phone applications page & gt; (this); Base.OnNavigatedTo (e); }  

But there are two problems in this, the code behind the first code is getting the code. Second, View MODEL, without making a wrapper class for the phone applications page object, the openjetted form and onVintingo event Can not tell the difference between (see update below).

What is the most MVVM-light friendly way to handle these incidents?

UPDATE: I am resolving another issue by sending a message like this:

  safe override minus renewedForm (system.NavigationEvent.arges e) {Messenger.Default. Send & lt; PhoneApplicationPage & gt; (This, "navigated"); Base.OnNavigatedFrom (E); } To override safe override zero (System.windows.navigation.navigationEventArgase E) {Messenger.Default. Send & lt; Phone applications page & gt; (This, "navigated"); Base.OnNavigatedTo (e); }  

and register them like this:

  Messenger.Default. Registrar & lt; Phone applications page & gt; (This, "Navigated", Wrong, (verb) => Sevastate (Action)); Messenger.Default.Register & lt; PhoneApplicationPage & gt; (This, "navigated", wrong, (action) => restoration (action);); Execution of a command from behind the code is far cleaner than going through the messaging mess.  

  Protected Override Zero Nonnovated (System.windows.navigation.NavigationEventAgagesE) {base.OnNigigatedTo (e); ViewModel.NavigatedToCommand.Execute (e.Uri); } ProfileViewModelViewModel {Get it} Go to this DataTontx profile as ViewModel; }}  

Update: Passing in NavigationContext.QueryString is probably more useful because it already parses the parameter and value.


Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -