Best WinAppDriver code snippet using AppUIBasics.Common.LoadStateEventArgs
NavigationHelper.cs
Source:NavigationHelper.cs  
...37    ///         this.navigationHelper.LoadState += navigationHelper_LoadState;38    ///         this.navigationHelper.SaveState += navigationHelper_SaveState;39    ///     }40    ///41    ///     private void navigationHelper_LoadState(object sender, LoadStateEventArgs e)42    ///     { }43    ///     private void navigationHelper_SaveState(object sender, LoadStateEventArgs e)44    ///     { }45    /// </code>46    ///47    /// 2) Register the page to call into the NavigationManager whenever the page participates48    ///     in navigation by overriding the <see cref="Windows.UI.Xaml.Controls.Page.OnNavigatedTo"/>49    ///     and <see cref="Windows.UI.Xaml.Controls.Page.OnNavigatedFrom"/> events.50    /// <code>51    ///     protected override void OnNavigatedTo(NavigationEventArgs e)52    ///     {53    ///         navigationHelper.OnNavigatedTo(e);54    ///     }55    ///56    ///     protected override void OnNavigatedFrom(NavigationEventArgs e)57    ///     {58    ///         navigationHelper.OnNavigatedFrom(e);59    ///     }60    /// </code>61    /// </example>62    [Windows.Foundation.Metadata.WebHostHidden]63    public class NavigationHelper : DependencyObject64    {65        private Page Page { get; set; }66        private Frame Frame { get { return this.Page.Frame; } }67        /// <summary>68        /// Initializes a new instance of the <see cref="NavigationHelper"/> class.69        /// </summary>70        /// <param name="page">A reference to the current page used for navigation.71        /// This reference allows for frame manipulation.</param>72        public NavigationHelper(Page page)73        {74            this.Page = page;75        }76        #region Process lifetime management77        private string _pageKey;78        /// <summary>79        /// Handle this event to populate the page using content passed80        /// during navigation as well as any state that was saved by81        /// the SaveState event handler.82        /// </summary>83        public event LoadStateEventHandler LoadState;84        /// <summary>85        /// Handle this event to save state that can be used by86        /// the LoadState event handler. Save the state in case87        /// the application is suspended or the page is discarded88        /// from the navigation cache.89        /// </summary>90        public event SaveStateEventHandler SaveState;91        /// <summary>92        /// Invoked when this page is about to be displayed in a Frame.93        /// This method calls <see cref="LoadState"/>, where all page specific94        /// navigation and process lifetime management logic should be placed.95        /// </summary>96        /// <param name="e">Event data that describes how this page was reached.  The Parameter97        /// property provides the group to be displayed.</param>98        public void OnNavigatedTo(NavigationEventArgs e)99        {100            var frameState = SuspensionManager.SessionStateForFrame(this.Frame);101            this._pageKey = "Page-" + this.Frame.BackStackDepth;102            if (e.NavigationMode == NavigationMode.New)103            {104                // Clear existing state for forward navigation when adding a new page to the105                // navigation stack106                var nextPageKey = this._pageKey;107                int nextPageIndex = this.Frame.BackStackDepth;108                while (frameState.Remove(nextPageKey))109                {110                    nextPageIndex++;111                    nextPageKey = "Page-" + nextPageIndex;112                }113                // Pass the navigation parameter to the new page114                this.LoadState?.Invoke(this, new LoadStateEventArgs(e.Parameter, null));115            }116            else117            {118                // Pass the navigation parameter and preserved page state to the page, using119                // the same strategy for loading suspended state and recreating pages discarded120                // from cache121                this.LoadState?.Invoke(this, new LoadStateEventArgs(e.Parameter, (Dictionary<string, object>)frameState[this._pageKey]));122            }123        }124        /// <summary>125        /// Invoked when this page will no longer be displayed in a Frame.126        /// This method calls <see cref="SaveState"/>, where all page specific127        /// navigation and process lifetime management logic should be placed.128        /// </summary>129        /// <param name="e">Event data that describes how this page was reached.  The Parameter130        /// property provides the group to be displayed.</param>131        public void OnNavigatedFrom(NavigationEventArgs e)132        {133            var frameState = SuspensionManager.SessionStateForFrame(this.Frame);134            var pageState = new Dictionary<string, object>();135            this.SaveState?.Invoke(this, new SaveStateEventArgs(pageState));136            frameState[_pageKey] = pageState;137        }138        #endregion139    }140    /// <summary>141    /// RootFrameNavigationHelper registers for standard mouse and keyboard142    /// shortcuts used to go back and forward. There should be only one143    /// RootFrameNavigationHelper per view, and it should be associated with the144    /// root frame.145    /// </summary>146    /// <example>147    /// To make use of RootFrameNavigationHelper, create an instance of the148    /// RootNavigationHelper such as in the constructor of your root page.149    /// <code>150    ///     public MyRootPage()151    ///     {152    ///         this.InitializeComponent();153    ///         this.rootNavigationHelper = new RootNavigationHelper(MyFrame);154    ///     }155    /// </code>156    /// </example>157    [Windows.Foundation.Metadata.WebHostHidden]158    public class RootFrameNavigationHelper159    {160        private Frame Frame { get; set; }161        SystemNavigationManager systemNavigationManager;162        private Microsoft.UI.Xaml.Controls.NavigationView CurrentNavView { get; set; }163        /// <summary>164        /// Initializes a new instance of the <see cref="RootNavigationHelper"/> class.165        /// </summary>166        /// <param name="rootFrame">A reference to the top-level frame.167        /// This reference allows for frame manipulation and to register navigation handlers.</param>168        public RootFrameNavigationHelper(Frame rootFrame, Microsoft.UI.Xaml.Controls.NavigationView currentNavView)169        {170            this.Frame = rootFrame;171            this.Frame.Navigated += (s, e) =>172            {173                // Update the Back button whenever a navigation occurs.174                UpdateBackButton();175            };176            this.CurrentNavView = currentNavView;177            // Handle keyboard and mouse navigation requests178            this.systemNavigationManager = SystemNavigationManager.GetForCurrentView();179            systemNavigationManager.BackRequested += SystemNavigationManager_BackRequested;180            // must register back requested on navview181            if (ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 6))182            {183                CurrentNavView.BackRequested += NavView_BackRequested;184            }185            // Listen to the window directly so we will respond to hotkeys regardless186            // of which element has focus.187            Window.Current.CoreWindow.Dispatcher.AcceleratorKeyActivated +=188                CoreDispatcher_AcceleratorKeyActivated;189            Window.Current.CoreWindow.PointerPressed +=190                this.CoreWindow_PointerPressed;191        }192        private void NavView_BackRequested(Microsoft.UI.Xaml.Controls.NavigationView sender, Microsoft.UI.Xaml.Controls.NavigationViewBackRequestedEventArgs args)193        {194            TryGoBack();195        }196        private bool TryGoBack()197        {198            // don't go back if the nav pane is overlayed199            if (this.CurrentNavView.IsPaneOpen && (this.CurrentNavView.DisplayMode == Microsoft.UI.Xaml.Controls.NavigationViewDisplayMode.Compact || this.CurrentNavView.DisplayMode == Microsoft.UI.Xaml.Controls.NavigationViewDisplayMode.Minimal))200            {201                return false;202            }203            bool navigated = false;204            if (this.Frame.CanGoBack)205            {206                this.Frame.GoBack();207                navigated = true;208            }209            210            return navigated;211        }212        private bool TryGoForward()213        {214            bool navigated = false;215            if (this.Frame.CanGoForward)216            {217                this.Frame.GoForward();218                navigated = true;219            }220            return navigated;221        }222        private void SystemNavigationManager_BackRequested(object sender, BackRequestedEventArgs e)223        {224            if (!e.Handled)225            {226                e.Handled = TryGoBack();227            }228        }229        private void UpdateBackButton()230        {231            if (ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 6))232            {233                this.CurrentNavView.IsBackEnabled = this.Frame.CanGoBack ? true : false;234            } else235            {236                systemNavigationManager.AppViewBackButtonVisibility = this.Frame.CanGoBack ? AppViewBackButtonVisibility.Visible : AppViewBackButtonVisibility.Collapsed;237            }238            239        }240        /// <summary>241        /// Invoked on every keystroke, including system keys such as Alt key combinations.242        /// Used to detect keyboard navigation between pages even when the page itself243        /// doesn't have focus.244        /// </summary>245        /// <param name="sender">Instance that triggered the event.</param>246        /// <param name="e">Event data describing the conditions that led to the event.</param>247        private void CoreDispatcher_AcceleratorKeyActivated(CoreDispatcher sender,248            AcceleratorKeyEventArgs e)249        {250            var virtualKey = e.VirtualKey;251            // Only investigate further when Left, Right, or the dedicated Previous or Next keys252            // are pressed253            if ((e.EventType == CoreAcceleratorKeyEventType.SystemKeyDown ||254                e.EventType == CoreAcceleratorKeyEventType.KeyDown) &&255                (virtualKey == VirtualKey.Left || virtualKey == VirtualKey.Right ||256                (int)virtualKey == 166 || (int)virtualKey == 167))257            {258                var coreWindow = Window.Current.CoreWindow;259                var downState = CoreVirtualKeyStates.Down;260                bool menuKey = (coreWindow.GetKeyState(VirtualKey.Menu) & downState) == downState;261                bool controlKey = (coreWindow.GetKeyState(VirtualKey.Control) & downState) == downState;262                bool shiftKey = (coreWindow.GetKeyState(VirtualKey.Shift) & downState) == downState;263                bool noModifiers = !menuKey && !controlKey && !shiftKey;264                bool onlyAlt = menuKey && !controlKey && !shiftKey;265                if (((int)virtualKey == 166 && noModifiers) ||266                    (virtualKey == VirtualKey.Left && onlyAlt))267                {268                    // When the previous key or Alt+Left are pressed navigate back269                    e.Handled = TryGoBack();270                }271                else if (((int)virtualKey == 167 && noModifiers) ||272                    (virtualKey == VirtualKey.Right && onlyAlt))273                {274                    // When the next key or Alt+Right are pressed navigate forward275                    e.Handled = TryGoForward();276                }277            }278        }279        /// <summary>280        /// Invoked on every mouse click, touch screen tap, or equivalent interaction.281        /// Used to detect browser-style next and previous mouse button clicks282        /// to navigate between pages.283        /// </summary>284        /// <param name="sender">Instance that triggered the event.</param>285        /// <param name="e">Event data describing the conditions that led to the event.</param>286        private void CoreWindow_PointerPressed(CoreWindow sender,287            PointerEventArgs e)288        {289            var properties = e.CurrentPoint.Properties;290            // Ignore button chords with the left, right, and middle buttons291            if (properties.IsLeftButtonPressed || properties.IsRightButtonPressed ||292                properties.IsMiddleButtonPressed)293                return;294            // If back or forward are pressed (but not both) navigate appropriately295            bool backPressed = properties.IsXButton1Pressed;296            bool forwardPressed = properties.IsXButton2Pressed;297            if (backPressed ^ forwardPressed)298            {299                e.Handled = true;300                if (backPressed) this.TryGoBack();301                if (forwardPressed) this.TryGoForward();302            }303        }304    }305    /// <summary>306    /// Represents the method that will handle the <see cref="NavigationHelper.LoadState"/>event307    /// </summary>308    public delegate void LoadStateEventHandler(object sender, LoadStateEventArgs e);309    /// <summary>310    /// Represents the method that will handle the <see cref="NavigationHelper.SaveState"/>event311    /// </summary>312    public delegate void SaveStateEventHandler(object sender, SaveStateEventArgs e);313    /// <summary>314    /// Class used to hold the event data required when a page attempts to load state.315    /// </summary>316    public class LoadStateEventArgs : EventArgs317    {318        /// <summary>319        /// The parameter value passed to <see cref="Frame.Navigate(Type, object)"/>320        /// when this page was initially requested.321        /// </summary>322        public object NavigationParameter { get; private set; }323        /// <summary>324        /// A dictionary of state preserved by this page during an earlier325        /// session.  This will be null the first time a page is visited.326        /// </summary>327        public Dictionary<string, object> PageState { get; private set; }328        /// <summary>329        /// Initializes a new instance of the <see cref="LoadStateEventArgs"/> class.330        /// </summary>331        /// <param name="navigationParameter">332        /// The parameter value passed to <see cref="Frame.Navigate(Type, object)"/>333        /// when this page was initially requested.334        /// </param>335        /// <param name="pageState">336        /// A dictionary of state preserved by this page during an earlier337        /// session.  This will be null the first time a page is visited.338        /// </param>339        public LoadStateEventArgs(object navigationParameter, Dictionary<string, object> pageState)340            : base()341        {342            this.NavigationParameter = navigationParameter;343            this.PageState = pageState;344        }345    }346    /// <summary>347    /// Class used to hold the event data required when a page attempts to save state.348    /// </summary>349    public class SaveStateEventArgs : EventArgs350    {351        /// <summary>352        /// An empty dictionary to be populated with serializable state.353        /// </summary>...InterviewPage.xaml.cs
Source:InterviewPage.xaml.cs  
...95        /// <param name="e">Event data that provides both the navigation parameter passed to96        /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested and97        /// a dictionary of state preserved by this page during an earlier98        /// session.  The state will be null the first time a page is visited.</param>99        private async void navigationHelper_LoadState(object sender, LoadStateEventArgs e)100        {101            var config = await InterviewerDataSource.GetConfiguration();102            Configuration = config;103            MainViewModel.ViewModel.SelectedConfiguration = config;104            this.DataContext = MainViewModel.ViewModel;105        }        106        private void SearchBox_QuerySubmitted(SearchBox sender, SearchBoxQuerySubmittedEventArgs args)107        {108            //this.Frame.Navigate(typeof(SearchResultsPage), args.QueryText);109        }110        #region NavigationHelper registration111        /// The methods provided in this section are simply used to allow112        /// NavigationHelper to respond to the page's navigation methods.113        /// ...LoadStateEventArgs
Using AI Code Generation
1using AppUIBasics.Common;2using Windows.UI.Xaml;3using Windows.UI.Xaml.Controls;4using Windows.UI.Xaml.Navigation;5{6    {7        public Scenario1()8        {9            this.InitializeComponent();10            this.LoadState += Scenario1_LoadState;11        }12        private void Scenario1_LoadState(object sender, LoadStateEventArgs e)13        {14            string value = e.PageState["Value"] as string;15            if (value != null)16            {17            }18        }19    }20}21using Windows.UI.Xaml.Controls;22using Windows.UI.Xaml.Navigation;23{24    {25        public Scenario2()26        {27            this.InitializeComponent();28        }29        protected override void OnNavigatedTo(NavigationEventArgs e)30        {31            string value = e.Parameter as string;32            if (value != null)33            {34            }35        }36    }37}38using Windows.UI.Xaml.Controls;39using Windows.UI.Xaml.Navigation;40{41    {42        public Scenario3()43        {44            this.InitializeComponent();45        }46        protected override void OnNavigatedTo(NavigationEventArgs e)47        {48            string value = e.Parameter as string;49            if (value != null)50            {51            }52        }53    }54}55using Windows.UI.Xaml.Controls;56using Windows.UI.Xaml.Navigation;57{58    {59        public Scenario4()60        {61            this.InitializeComponent();62        }63        protected override void OnNavigatedTo(NavigationEventArgs e)64        {65            string value = e.Parameter as string;66            if (value != null)67            {68            }69        }70    }71}72using Windows.UI.Xaml.Controls;73using Windows.UI.Xaml.Navigation;74{LoadStateEventArgs
Using AI Code Generation
1using AppUIBasics.Common;2using Windows.UI.Xaml;3using Windows.UI.Xaml.Controls;4{5    {6        public Scenario1()7        {8            this.InitializeComponent();9        }10        private void Page_Loaded(object sender, RoutedEventArgs e)11        {12            object obj = ((App)App.Current).LoadStateEventArgs.LoadedObject;13            if (obj != null)14            {15                string str = obj as string;16                TextBlock.Text = str;17            }18        }19    }20}21using AppUIBasics.Common;22using Windows.UI.Xaml;23using Windows.UI.Xaml.Controls;24{25    {26        public Scenario2()27        {28            this.InitializeComponent();29        }30        private void Page_Loaded(object sender, RoutedEventArgs e)31        {32            object obj = ((App)App.Current).LoadStateEventArgs.LoadedObject;33            if (obj != null)34            {35                int number = (int)obj;36                TextBlock.Text = number.ToString();37            }38        }39    }40}41using AppUIBasics.Common;42using Windows.UI.Xaml;43using Windows.UI.Xaml.Controls;44{45    {46        public Scenario3()47        {48            this.InitializeComponent();49        }50        private void Page_Loaded(object sender, RoutedEventArgs e)51        {52            object obj = ((App)App.Current).LoadStateEventArgs.LoadedObject;53            if (obj != null)54            {LoadStateEventArgs
Using AI Code Generation
1using AppUIBasics.Common;2using AppUIBasics.Data;3using AppUIBasics.ViewModels;4using Windows.UI.Xaml.Controls;5using Windows.UI.Xaml.Navigation;6{7    {8        public Scenario1()9        {10            this.InitializeComponent();11        }12        protected override void OnNavigatedTo(NavigationEventArgs e)13        {14            var loadStateEventArgs = e.Parameter as LoadStateEventArgs;15            var sampleDataItem = loadStateEventArgs.NavigationParameter as SampleDataItem;16            var viewModel = new Scenario1ViewModel();17            viewModel.Initialize(sampleDataItem);18            this.DataContext = viewModel;19        }20    }21}22    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">23        <TextBlock Text="{x:Bind ViewModel.ItemTitle}"24                   Style="{ThemeResource TitleTextBlockStyle}"25        <TextBlock Text="{x:Bind ViewModel.ItemContent}"26                   Style="{ThemeResource BodyTextBlockStyle}"27using AppUIBasics.Common;28using AppUIBasics.Data;29using AppUIBasics.ViewModels;30using Windows.UI.Xaml.Controls;31using Windows.UI.Xaml.Navigation;32{LoadStateEventArgs
Using AI Code Generation
1using LoadStateEventArgs = AppUIBasics.Common.LoadStateEventArgs;2using NavigationHelper = AppUIBasics.Common.NavigationHelper;3using ObservableDictionary = AppUIBasics.Common.ObservableDictionary;4using SuspensionManager = AppUIBasics.Common.SuspensionManager;5using LoadStateEventArgs = AppUIBasics.Common.LoadStateEventArgs;6using NavigationHelper = AppUIBasics.Common.NavigationHelper;7using ObservableDictionary = AppUIBasics.Common.ObservableDictionary;8using SuspensionManager = AppUIBasics.Common.SuspensionManager;9using LoadStateEventArgs = AppUIBasics.Common.LoadStateEventArgs;10using NavigationHelper = AppUIBasics.Common.NavigationHelper;11using ObservableDictionary = AppUIBasics.Common.ObservableDictionary;12using SuspensionManager = AppUIBasics.Common.SuspensionManager;13using LoadStateEventArgs = AppUIBasics.Common.LoadStateEventArgs;14using NavigationHelper = AppUIBasics.Common.NavigationHelper;15using ObservableDictionary = AppUIBasics.Common.ObservableDictionary;16using SuspensionManager = AppUIBasics.Common.SuspensionManager;17using LoadStateEventArgs = AppUIBasics.Common.LoadStateEventArgs;18using NavigationHelper = AppUIBasics.Common.NavigationHelper;LoadStateEventArgs
Using AI Code Generation
1using AppUIBasics.Common;2using Windows.Storage;3using Windows.Storage.Pickers;4using Windows.Storage.Provider;5using Windows.UI.Xaml;6using Windows.UI.Xaml.Controls;7using Windows.UI.Xaml.Navigation;8{9    {10        private NavigationHelper navigationHelper;11        private ObservableDictionary defaultViewModel = new ObservableDictionary();12        public Scenario1()13        {14            this.InitializeComponent();15            navigationHelper = new NavigationHelper(this);16            navigationHelper.LoadState += navigationHelper_LoadState;17            navigationHelper.SaveState += navigationHelper_SaveState;18        }19        {20            get { return this.navigationHelper; }21        }22        {23            get { return this.defaultViewModel; }24        }25        private async void navigationHelper_LoadState(object sender, LoadStateEventArgs e)26        {27            if (e.PageState != null && e.PageState.ContainsKey("text"))28            {29                OutputTextBlock.Text = e.PageState["text"].ToString();30            }31            {32                StorageFile file = await ApplicationData.Current.LocalFolder.TryGetItemAsync("sample.dat") as StorageFile;33                if (file != null)34                {35                    OutputTextBlock.Text = await FileIO.ReadTextAsync(file);36                }37            }38        }39        private async void navigationHelper_SaveState(object sender, SaveStateEventArgs e)40        {41            StorageFile file = await ApplicationData.Current.LocalFolder.CreateFileAsync("sample.dat", CreationCollisionOption.ReplaceExisting);42            await FileIO.WriteTextAsync(file, OutputTextBlock.Text);43            e.PageState["text"] = OutputTextBlock.Text;44        }45        protected override void OnNavigatedTo(NavigationEventArgs e)46        {47            navigationHelper.OnNavigatedTo(e);48        }49        protected override void OnNavigatedFrom(NavigationEventArgs e)50        {51            navigationHelper.OnNavigatedFrom(e);52        }53    }54}LoadStateEventArgs
Using AI Code Generation
1using AppUIBasics.Common;2using AppUIBasics.Data;3using AppUIBasics.ViewModels;4using Windows.UI.Xaml.Controls;5{6    {7        public NavigationViewPage()8        {9            this.InitializeComponent();10            this.Loaded += OnLoaded;11        }12        private void OnLoaded(object sender, Windows.UI.Xaml.RoutedEventArgs e)13        {14            var viewModel = (NavigationViewViewModel)this.DataContext;15            var args = (LoadStateEventArgs)this.NavigationContext;16            viewModel.Initialize(args.NavigationParameter, args.PageState);17        }18    }19}20using AppUIBasics.Common;21using AppUIBasics.Data;22using AppUIBasics.ViewModels;23using Windows.UI.Xaml.Controls;24{25    {26        public NavigationViewPage()27        {28            this.InitializeComponent();29            this.Loaded += OnLoaded;30        }31        private void OnLoaded(object sender, Windows.UI.Xaml.RoutedEventArgs e)32        {33            var viewModel = (NavigationViewViewModel)this.DataContext;34            var args = (LoadStateEventArgs)this.NavigationContext;35            viewModel.Initialize(args.NavigationParameter, args.PageState);36        }37    }38}39using AppUIBasics.Common;40using AppUIBasics.Data;41using AppUIBasics.ViewModels;42using Windows.UI.Xaml.Controls;43{44    {45        public NavigationViewPage()46        {47            this.InitializeComponent();48            this.Loaded += OnLoaded;49        }50        private void OnLoaded(object sender, Windows.UI.Xaml.RoutedEventArgs e)51        {52            var viewModel = (NavigationViewViewModel)this.DataContext;53            var args = (LoadStateEventArgs)this.NavigationContext;54            viewModel.Initialize(args.NavigationParameter, args.PageState);55        }56    }57}58using AppUIBasics.Common;59using AppUIBasics.Data;60using AppUIBasics.ViewModels;61using Windows.UI.Xaml.Controls;62{LoadStateEventArgs
Using AI Code Generation
1using AppUIBasics.Common;2using AppUIBasics;3using AppUIBasics.Data;4using AppUIBasics.DataModel;5using AppUIBasics.ViewModel;6using AppUIBasics.Views;7using AppUIBasics.Controls;8using AppUIBasics.Common;9using AppUIBasics;10using AppUIBasics.Data;11using AppUIBasics.DataModel;12using AppUIBasics.ViewModel;13using AppUIBasics.Views;14using AppUIBasics.Controls;15using AppUIBasics.Common;16using AppUIBasics;17using AppUIBasics.Data;18using AppUIBasics.DataModel;19using AppUIBasics.ViewModel;20using AppUIBasics.Views;21using AppUIBasics.Controls;22using AppUIBasics.Common;LoadStateEventArgs
Using AI Code Generation
1using AppUIBasics.Common;2using Windows.UI.Xaml.Controls;3using Windows.UI.Xaml.Navigation;4{5    public Scenario1()6    {7        this.InitializeComponent();8    }9    protected override void OnNavigatedTo(NavigationEventArgs e)10    {11        LoadStateEventArgs loadState = e.Parameter as LoadStateEventArgs;12        if (loadState != null)13        {14            if (loadState.PageState.ContainsKey("TextBoxValue"))15            {16                textBox.Text = (string)loadState.PageState["TextBoxValue"];17            }18        }19    }20    protected override void OnNavigatedFrom(NavigationEventArgs e)21    {22        SaveStateEventArgs saveState = new SaveStateEventArgs();23        saveState.PageState["TextBoxValue"] = textBox.Text;24        e.Parameter = saveState;25    }26}27using AppUIBasics.Common;28using Windows.UI.Xaml.Controls;29using Windows.UI.Xaml.Navigation;30{31    public Scenario2()32    {33        this.InitializeComponent();34    }35    protected override void OnNavigatedTo(NavigationEventArgs e)36    {37        LoadStateEventArgs loadState = e.Parameter as LoadStateEventArgs;38        if (loadState != null)39        {40            if (loadState.PageState.ContainsKey("TextBoxValue"))41            {42                textBox.Text = (string)loadState.PageState["TextBoxValue"];43            }44        }45    }46    protected override void OnNavigatedFrom(NavigationEventArgs e)47    {Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
