Show/hide Mahapps 弹出控件

Show/hide Mahapps Flyout control

我如何 show/hide MahApps Flyout 控制?现在我有:

<controls:FlyoutsControl>
    <controls:Flyout Header="Flyout" Position="Right" Width="200" IsOpen="True">
        <TextBlock FontSize="24">Hello World</TextBlock>
    </controls:Flyout>
</controls:FlyoutsControl>

它是打开的,但是当我点击带箭头的按钮时,我无法再次显示它。

你可以简单地使用这样的东西:

yourMahAppFlyout.IsOpen = true;

您还可以将 Flyout 可见性绑定到 WindowCommand (LeftWindowCommand/RightWindowCommand),因此无论何时关闭 Flyout,您都可以使用 ToggleButton 重新打开(对于例如)从 window.

的顶部开始
<Controls:MetroWindow.Flyouts>
    <Controls:FlyoutsControl>
        <Controls:Flyout x:Name="yourMahAppFlyout"/>
    </Controls:FlyoutsControl>
</Controls:MetroWindow.Flyouts>

<Controls:MetroWindow.RightWindowCommands>
    <Controls:WindowCommands>
        <ToggleButton Content="Layers" 
        IsChecked="{Binding ElementName=yourMahAppFlyout, Path=IsOpen}" Cursor="Hand"/>               
    </Controls:WindowCommands>
</Controls:MetroWindow.RightWindowCommands>