private void HideFullWindowPopupOnNavigating(FullWindowPopup popup) { this.Frame.Navigating += (sender, e) => { popup.Hide(); }; }
private void Button3_Click(object sender, RoutedEventArgs e) { FullWindowPopup popup = new FullWindowPopup(); var child = (Grid)XamlReader.Load( @"<Grid xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"" xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"" xmlns:mc=""http://schemas.openxmlformats.org/markup-compatibility/2006"" Background=""Blue"" VerticalAlignment=""Top""> <StackPanel> <TextBlock Text=""Title"" FontSize=""18""/> <TextBlock Text=""Body"" FontSize=""15""/> </StackPanel> </Grid>" ); popup.Child = child; popup.Opened += Popup_Opened; popup.Closed += Popup_Closed; child.Tapped += async(s, args) => { popup.Hide(); txtMsg.Text = "点击了模拟 Toast。"; await Task.Delay(3000); txtMsg.Text = string.Empty; }; popup.Show(); HideFullWindowPopupOnNavigating(popup); }
/// <summary> /// 保留与此页关联的状态,以防挂起应用程序或 /// 从导航缓存中放弃此页。值必须符合 /// <see cref="SuspensionManager.SessionState"/> 的序列化要求。 /// </summary> /// <param name="sender">事件的来源;通常为 <see cref="NavigationHelper"/></param> ///<param name="e">提供要使用可序列化状态填充的空字典 ///的事件数据。</param> private void NavigationHelper_SaveState(object sender, SaveStateEventArgs e) { if (popup != null) { popup.Hide(); } }