如何防止嵌套WPF弹出窗口在屏幕外单击后关闭

如何防止嵌套WPF弹出窗口在屏幕外单击后关闭,wpf,wpftoolkit,Wpf,Wpftoolkit,解释问题的最简单方法是使用一些Xaml: <Window x:Class="NestedPopups.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="300" Width="525"> <Grid>

解释问题的最简单方法是使用一些Xaml:

<Window x:Class="NestedPopups.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="300" Width="525">
<Grid>
    <ToggleButton x:Name="b1" VerticalAlignment="Top" Width="50" Height="50"></ToggleButton>
    <Popup IsOpen="{Binding ElementName=b1, Path=IsChecked}" PlacementTarget="{Binding ElementName=b1}" Width="100" StaysOpen="False"
           Height="200">
        <Grid>
            <DatePicker HorizontalAlignment="Center" VerticalAlignment="Center">
            </DatePicker>
        </Grid>
    </Popup>
</Grid>
</Window>


使用日期选择器选择日期时,如果所选日期未与窗口边缘重叠,我将获得所需的行为,即弹出窗口保持打开状态。如果所选日期位于窗口边缘(底部两行的任何日期)之后,则弹出窗口关闭。防止这种行为的最佳方法是什么

尝试为
弹出窗口设置
StaysOpen=“True”
。我只希望在关闭日期时间选择器时弹出窗口保持打开状态。我可以在CalendarOpen/CalendarClosed事件之间将StaysOpen设置为true,这似乎可行,但我希望可能有一个没有代码隐藏的解决方案。日历上的IsOpen属性会很方便…你能截图并发布你正在经历的行为吗?