added samples
[windows-sources.git] / sdk / samples / WPFSamples / CustomContentStateNavigationSample / csharp / usercustomcontentstate.cs
blobfe27bf03f1e9c9a3481a3815f653c0893dc407f2
1 using System;
2 using System.Windows.Controls;
3 using System.Windows.Navigation;
5 namespace CustomContentStateNavigationSample
7 [Serializable]
8 // This class encapsulates the current user data - the list selected index
9 class UserCustomContentState : CustomContentState
11 private User user;
13 public UserCustomContentState(User user)
15 this.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
22 get
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;