27

How can I show/hide MahApps Flyout control? Now I have:

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

And it's open, but when I click the button with arrow I can't show it again.

Hossein Narimani Rad
  • 31,361
  • 18
  • 86
  • 116
mskuratowski
  • 4,014
  • 15
  • 58
  • 109

1 Answers1

48

You can simply use something like this:

yourMahAppFlyout.IsOpen = true;

Also you can bind the Flyout visibility to a WindowCommand (LeftWindowCommand/RightWindowCommand) so whenever you close the Flyout you can reopen using a ToggleButton (for example) from the top of the 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>
Alejandro
  • 7,290
  • 4
  • 34
  • 59
Hossein Narimani Rad
  • 31,361
  • 18
  • 86
  • 116