-2

I'm trying to close a flyout when a click on his or on another side of the window, I use the ExternalCloseButton=Left property. Is this okay? I also tried removing the property AutoCloseEnabled, but could not get results.

When I use a flyout with the property EnabledAutoClose, when closed, the focus is lost in the control it was.

You can help solve this problem?

<mahApps:MetroWindow.Flyouts>
    <mahApps:FlyoutsControl>
        <mahApps:Flyout Position="Bottom"
                        AutoCloseInterval="3000"
                        IsOpen="{Binding IsOpen}"
                        IsAutoCloseEnabled="True"
                        ExternalCloseButton="Left">
        </mahApps:Flyout>
    </mahApps:FlyoutsControl>
</mahApps:MetroWindow.Flyouts>
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
avechuche
  • 1,470
  • 6
  • 28
  • 45

2 Answers2

1

If you set IsPinned="False" then the Flyout will be closed on left mouse click outside the Flyout.

<Controls:Flyout Height="75"
                 CloseButtonVisibility="Collapsed"
                 IsPinned="False"
                 Position="Bottom"
                 TitleVisibility="Collapsed">
    <TextBlock VerticalAlignment="Center" Text="This is an AppBar" />
</Controls:Flyout>

Sample is from the main demo. Hope this helps.

punker76
  • 14,326
  • 5
  • 58
  • 96
0

You can use PreviewMouseLeftButtonUp of the MainWindow or whatever view contains the flyout and set the isOpen to false. If you want to close it only when user clicks the outside of the flyout than you can check it with isMouseOver property of the flyout.

Mertus
  • 1,145
  • 11
  • 17