BuildIt.MvvmCross.UI.Views.BaseStateEnabledPage.OnNavigatedTo C# (CSharp) Method

OnNavigatedTo() protected method

protected OnNavigatedTo ( NavigationEventArgs e ) : void
e NavigationEventArgs
return void
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            try
            {
                DumpExistingViewModel(e);


                base.OnNavigatedTo(e);

#if WINDOWS_PHONE_APP
                HardwareButtons.BackPressed += HardwareButtons_BackPressed;

#elif WINDOWS_UWP
                if (Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons"))
                {
                    Windows.Phone.UI.Input.HardwareButtons.BackPressed += HardwareButtons_BackPressed;
                }

                if (CanSubscribeToBackRequest)
                {
                    SubscribeToBackRequestedEvent();
                }
                if (AutomaticallyShowAppViewBackButton)
                {
                    if (DisplayAppViewBackButton)
                    {
                        var rootFrame = Window.Current.Content as Frame;
                        if (rootFrame != null)
                        {
                            SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility =
                                rootFrame.CanGoBack
                                    ? AppViewBackButtonVisibility.Visible
                                    : AppViewBackButtonVisibility.Collapsed;
                        }
                    }
                }
#endif
                if (GoBackViewModel != null)
                {
                    GoBackViewModel.ClearPreviousViews += ClearViews;
                }

                var satvm = StatesAndTransitionsViewModel;
                if (satvm != null)
                {
                    satvm.StateChanged += ViewModelStateChanged;
                    satvm.RunStoryboard += RunStoryboard;
                    satvm.StopStoryboard += StopStoryboard;

                    // Force a refresh of all current states
                    satvm.RefreshStates();
                }

                var bvm = ViewModel as BaseViewModel;
                if (bvm != null)

                {
                    await bvm.WaitForStartCompleted();
                }

                await OnNavigatedToCompleted();

            }
            catch (Exception exception)
            {
                Debug.WriteLine(exception.Message);
            }
        }