如何在屏幕外点击后阻止嵌套的WPF弹出窗口关闭

时间:2013-08-16 13:02:30

标签: 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>
    <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>

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

0 个答案:

没有答案
相关问题