Sep 13, 2011 at 3:22 AM
Edited Sep 13, 2011 at 4:04 AM
Hi, first of all, thanks for the library.
[edited item 1, because found the answer on the sample code]
The method on the base class is different than the one overriden:
protected override void OnNavigatingFrom(System.Windows.Navigation.NavigatingCancelEventArgs e)
Second, on the sample below, the event e is not being passed in the generic version. I see it can be passed on the routine itself (the overload exists). Should we pass it or is it even ignored. If so, shouldn't be mandatory to ensure
future compatibility? e is included in the basic sample after all...
this.SaveState<ListBox, TextBox>(); <-- e is missing
Sep 19, 2011 at 8:14 PM
Yes, item 1 is a typo. I updated the sample when I added support for the NavigatING version but must have missed the base method.
Actually, it's not necessary to call the base methods at all as they don't actually do anything. (Must blog about this soon.)
When it comes to calling SaveState, passing the NavigatingCancelEventArgs is completely optional and only available in OnNavigatINGFrom, not OnNavigtEDFrom.
I'd recommend always passing it as it will improve performance when navigating is triggered by pressing the hardware back button.
It's optional to maintain backwards compatibility with the first version of this library which only supported OnNavigatEDFrom.
I'll update the sample code to always use best practice.