我正在将一个Flyout附加到LayoutRoot网格.
<Page.Resources> <Flyout x:Key="WinningPopup"> <StackPanel Margin="50,10"> <TextBlock x:Uid="Flyout_VictoryTitle" Text="Victory!" Style="{StaticResource MessageDialogTitleStyle}" Margin="0,15"/> <TextBlock x:Name="Flyout_VictoryDescription" x:Uid="Flyout_VictoryDescription" Text="Congratulations!
score: " Style="{StaticResource MessageDialogContentStyle}" /> <StackPanel Orientation="Horizontal"> <Button x:Name="btnRestart" x:Uid="btnRestart" Click="btnRestart_Click" Content="[Restart]" Margin="10"/> <Button x:Name="btnCancel" x:Uid="btnCancel" Click="btnCancel_Click" Content="[Cancel]" Margin="10"/> </StackPanel> </StackPanel> </Flyout> </Page.Resources> <Grid x:Name="LayoutRoot" FlyoutBase.AttachedFlyout="{StaticResource WinningPopup}"> ...
我打开这个Flyout
FlyoutBase.ShowAttachedFlyout(LayoutRoot);
解决方法
给它一个名字
<Page.Resources> <Flyout x:Name="myFlyout" x:Key="WinningPopup"> // ...... </Flyout> </Page.Resources>
然后你就可以隐藏()
myFlyout.Hide();