WPF弹出窗口无法在其边界之外单击

时间:2019-07-18 02:21:48

标签: wpf popup

在我的WPF应用程序中,我在ListBox的SelectionChanged事件上打开一个弹出窗口。我正在使用StaysOpen属性(设置为False)在其边界之外单击时打开/关闭Popup。但是我在关闭Popup时遇到了一个奇怪的行为-当我单击Popup之外但在WPF应用程序MainWindow边界内的任何位置时,它都不会关闭。但是,当我在WPF应用程序外部单击时,它将关闭(并且该应用程序进入后台)。

            <Popup
            PlacementTarget="{Binding ElementName=listInputSource}"
            Placement="Bottom"
            Closed="SourceSwitchPopUp_Closed"
            VerticalOffset="5"
            AllowsTransparency="True"
            PopupAnimation="Fade"
            StaysOpen="False">
                <ContentControl Name="SourceSwitchContentCtrl" Style="{StaticResource SourcePopUpContentStyle}"/>
            </Popup>

我希望在单击边界外的任何位置时都会关闭弹出窗口。

有什么建议吗?

谢谢

0 个答案:

没有答案