private Windows.Foundation.Collections.IPropertySet PageState(Page page) { if (page == null) { throw new ArgumentNullException(nameof(page)); } return NavigationService.Suspension.GetPageState(page.GetType()).Values; }
private void _textBox_TextChanged(object sender, TextChangedEventArgs e) { _page = _page ?? _textBox.Ancestor<Page>(); var field = _page.GetType().GetTypeInfo().GetDeclaredField("Bindings"); var bindings = field?.GetValue(_page); var update = bindings?.GetType().GetRuntimeMethod("Update", new Type[] { }); //update?.Invoke(bindings, null); }
/// <summary> /// Initializes a new instance of the <see cref="NavigationHelper"/> class. /// </summary> /// <param name="page">A reference to the current page used for navigation. /// This reference allows for frame manipulation and to ensure that keyboard /// navigation requests only occur when the page is occupying the entire window.</param> public NavigationHelper(Page page) { Page = page; // When this page is part of the visual tree make two changes: // 1) Map application view state to visual state for the page // 2) Handle hardware navigation requests Page.Loaded += (sender, e) => { KernelResolver.Current.Get<INavigationMediator>().RaisePageLoaded(Page.GetType()); #if WINDOWS_PHONE_APP Windows.Phone.UI.Input.HardwareButtons.BackPressed += HardwareButtons_BackPressed; #else // Keyboard and mouse navigation only apply when occupying the entire window if (this.Page.ActualHeight == Window.Current.Bounds.Height && this.Page.ActualWidth == Window.Current.Bounds.Width) { // Listen to the window directly so focus isn't required Window.Current.CoreWindow.Dispatcher.AcceleratorKeyActivated += CoreDispatcher_AcceleratorKeyActivated; Window.Current.CoreWindow.PointerPressed += this.CoreWindow_PointerPressed; } #endif }; // Undo the same changes when the page is no longer visible Page.Unloaded += (sender, e) => { #if WINDOWS_PHONE_APP Windows.Phone.UI.Input.HardwareButtons.BackPressed -= HardwareButtons_BackPressed; #else Window.Current.CoreWindow.Dispatcher.AcceleratorKeyActivated -= CoreDispatcher_AcceleratorKeyActivated; Window.Current.CoreWindow.PointerPressed -= this.CoreWindow_PointerPressed; #endif }; }
public static void Update(Page p, string s) { p.Frame.Navigate(p.GetType(), s); }
public static void Update(Page p) { p.Frame.Navigate(p.GetType(), ""); }
/// <summary> /// Attempts to sign the user into Snapchat. /// </summary> private async void SignIn(Page nextPage) { // Uncomment this to force login with a foreign Auth Token // // App.SnapChatManager.Account = new Account // { // Friends = new ObservableCollection<Friend>(), // AddedFriends = new ObservableCollection<AddedFriend>(), // BestFriends = new ObservableCollection<string>(), // Snaps = new ObservableCollection<Snap>(), // AuthToken = "", // Username = "******" // }; // App.SnapChatManager.AuthToken = ""; // App.SnapChatManager.Username = "******"; // await App.SnapChatManager.UpdateAllAsync(() => { }, App.Settings); // App.CurrentFrame.Navigate((typeof (MainPage))); //#if WINDOWS_PHONE_APP // await // App.MobileService.GetTable<User>() // .InsertAsync(new User // { // AuthExpired = false, // NewUser = true, // DeviceIdent = App.DeviceIdent, // SnapchatAuthToken = App.SnapChatManager.AuthToken, // SnapchatUsername = App.SnapChatManager.Username // }); //#endif // return; try { if (string.IsNullOrEmpty(CurrentUsername) || string.IsNullOrEmpty(CurrentPassword)) { var dialog = new MessageDialog(App.Loader.GetString("InvalidCredentialsBody"), App.Loader.GetString("InvalidCredentialsHeader")); await dialog.ShowAsync(); return; } #if WINDOWS_PHONE_APP // Tell UI we're Signing In StatusBar.GetForCurrentView().ProgressIndicator.Text = App.Loader.GetString("SigningIn"); await StatusBar.GetForCurrentView().ProgressIndicator.ShowAsync(); #endif ProgressModalVisibility = Visibility.Visible; ProgressModalIsVisible = true; // Try and log into SnapChat await App.SnapChatManager.Endpoints.AuthenticateAsync(CurrentUsername, CurrentPassword); // This is unnecessary here and slows down the sign in process significantly. xoxo, Matt /*try { await App.SnapChatManager.UpdateAllAsync(() => { }, App.Settings); } catch (InvalidHttpResponseException exception) { if (exception.Message == "Unauthorized") { var dialog = new MessageDialog(App.Loader.GetString("UnauthorizedBody"), App.Loader.GetString("UnauthorizedHeader")); dialog.ShowAsync(); } }*/ #if WINDOWS_PHONE_APP // Register device for Push Notifications await App.MobileService.GetTable<User>() .InsertAsync(new User { AuthExpired = false, NewUser = true, DeviceIdent = App.DeviceIdent, SnapchatAuthToken = App.SnapChatManager.AuthToken, SnapchatUsername = App.SnapChatManager.Username }); #endif } catch (InvalidCredentialsException) { var dialog = new MessageDialog(App.Loader.GetString("InvalidCredentialsBody"), App.Loader.GetString("InvalidCredentialsHeader")); dialog.ShowAsync(); } catch (InvalidHttpResponseException exception) { var dialog = new MessageDialog(String.Format("{0} \n {1}.", App.Loader.GetString("InvalidHttpBody"), exception.Message), App.Loader.GetString("InvalidHttpHeader")); dialog.ShowAsync(); } finally { // Tell UI we're not Signing In no mo' #if WINDOWS_PHONE_APP StatusBar.GetForCurrentView().ProgressIndicator.Text = String.Empty; StatusBar.GetForCurrentView().ProgressIndicator.HideAsync(); #endif ProgressModalVisibility = Visibility.Collapsed; ProgressModalIsVisible = false; } if ( App.SnapChatManager.Account == null || !App.SnapChatManager.Account.Logged || !App.SnapChatManager.IsAuthenticated()) { #if WINDOWS_PHONE_APP CurrentPassword = ""; //App.CurrentFrame.Navigate(typeof(StartPage), "removeBackStack"); #endif return; } App.CurrentFrame.Navigate(nextPage == null ? typeof(MainPage) : nextPage.GetType(), "removeBackStack"); }
public void Navigate(Page destination, string parameter = null) { Page page = MyFrame?.Content as Page; var @switch = new Dictionary<Type, Action> { { typeof(HomePage), () => { if (page?.GetType() != typeof(HomePage)) { MainPageViewModel.PageTitle = "Home"; MyFrame?.Navigate(typeof(HomePage)); } } }, { typeof(ProfilePage), () => { if (page?.GetType() != typeof(ProfilePage)) { MainPageViewModel.PageTitle = "Profile"; if (parameter != null) { int id = Convert.ToInt32(parameter); UserId = id; MyFrame?.Navigate(typeof(ProfilePage)); UserIdHistory.Add(id); } } } }, { typeof(FollowerPage), () => { if (page?.GetType() != typeof(FollowerPage)) { MainPageViewModel.PageTitle = "Followers"; if (parameter != null) { int id = Convert.ToInt32(parameter); UserId = id; MyFrame?.Navigate(typeof(FollowerPage)); UserIdHistory.Add(id); } } } }, { typeof(FollowingPage), () => { if (page?.GetType() != typeof(FollowingPage)) { MainPageViewModel.PageTitle = "Following"; if (parameter != null) { int id = Convert.ToInt32(parameter); UserId = id; MyFrame?.Navigate(typeof(FollowingPage)); UserIdHistory.Add(id); } } } }, { typeof(SearchPage), () => { if (page?.GetType() != typeof(SearchPage)) { MainPageViewModel.PageTitle = parameter; MyFrame?.Navigate(typeof(SearchPage), parameter); } } }, { typeof(PlaylistPage), () => { if (page?.GetType() != typeof(PlaylistPage)) { MainPageViewModel.PageTitle = "Playlist"; MyFrame?.Navigate(typeof(PlaylistPage)); } } }, { typeof(PlaylistViewPage), () => { if (page?.GetType() != typeof(PlaylistViewPage)) { MainPageViewModel.PageTitle = "Playlist"; MyFrame?.Navigate(typeof(PlaylistViewPage), parameter); } } } }; @switch[destination.GetType()](); if (ActualWidth < 720 && SplitViewMenu.IsPaneOpen) { SplitViewMenu.IsPaneOpen = false; } }