2 using System
.Windows
.Controls
;
3 using System
.Windows
.Navigation
;
5 namespace CustomContentStateNavigationSample
8 // This class encapsulates the current user data - the list selected index
9 class UserCustomContentState
: CustomContentState
13 public UserCustomContentState(User user
)
18 // Override this property to customize the name that appears in
19 // navigation history for this custom content state object.
20 public override string JournalEntryName
24 return this.user
.Name
;
28 // MANDATORY: Need to override this method to restore the required state.
29 // Since the "navigation" is not user-initiated ie. set by the user selecting
30 // a new ListBoxItem, we set the flag to false.
31 public override void Replay(NavigationService navigationService
, NavigationMode mode
)
33 StateNavigationPage page
= (StateNavigationPage
)navigationService
.Content
;
34 ListBox userListBox
= page
.userListBox
;
36 page
.userListBox
.SelectionChanged
-= page
.userListBox_SelectionChanged
;
37 page
.userListBox
.SelectedItem
= this.user
;
38 page
.userListBox
.SelectionChanged
+= page
.userListBox_SelectionChanged
;