C# WPF GridSplitter未进行命中测试?

C# WPF GridSplitter未进行命中测试?,c#,wpf,.net-4.0,gridsplitter,C#,Wpf,.net 4.0,Gridsplitter,我似乎在WPF GridSplitter上遇到了一个奇怪的问题 如果我这样做: <Window x:Class="WpfApplication20.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindo

我似乎在WPF GridSplitter上遇到了一个奇怪的问题

如果我这样做:

<Window x:Class="WpfApplication20.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="102" />
            <RowDefinition Height="1" />
            <RowDefinition Height="192" />
        </Grid.RowDefinitions>
        <GridSplitter Grid.Row="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" ResizeDirection="Rows" Background="Black"></GridSplitter>
        <Canvas Grid.Row="0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Background="AliceBlue"></Canvas>
        <Canvas Grid.Row="2" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Background="Yellow"></Canvas>       
    </Grid>
</Window>
这给了我一个奇怪的行为:最初Gridsplitter是以2px亚像素定位的高度绘制的?但所有网格行都是整数高度。如果我向上调整行的大小,GridSplitter将继续工作。如果我向下调整行的大小,我将到达绘制高度为1px的GridSplitter的点,一旦释放鼠标,我将无法再与GridSplitter交互

问题:

为什么GridSplitter在前两种情况下依赖于Z顺序工作? 为什么GridSplitter在第三种情况下间歇性工作?
我认为它在前两种情况下都有效,与z阶无关。当我尝试两者都使用时,但是仅仅一个像素高就很难命中。试着把它设为4像素,然后再试一次。实际上,如果我把第一个大小写改为2像素,它就可以工作了。但是使用1pxGridSplitter,我在两台不同的计算机上进行了尝试,但都不起作用。它对我在视网膜MBP2880*1800px上使用Windows8是有效的,但很难实现。你关于亚像素的预感可能是正确的,我建议你坚持使用>1像素的高度:另外,请看这里:感谢链接,但链接仅描述了如何确保gridsplitter在与其他元素相同的网格单元中可见。在这个问题中,我将把gridsplitter放在它自己的网格单元中,这是一个不同的问题。
<Window x:Class="WpfApplication20.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="102" />
            <RowDefinition Height="1" />
            <RowDefinition Height="192" />
        </Grid.RowDefinitions>
        <Canvas Grid.Row="0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Background="AliceBlue"></Canvas>
        <Canvas Grid.Row="2" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Background="Yellow"></Canvas>
        <GridSplitter Grid.Row="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" ResizeDirection="Rows" Background="Black"></GridSplitter>
</Grid>
</Window>
<Window x:Class="WpfApplication20.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525" UseLayoutRounding="True">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="102" />
            <RowDefinition Height="1" />
            <RowDefinition Height="192" />
        </Grid.RowDefinitions>
        <GridSplitter Grid.Row="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" ResizeDirection="Rows" Background="Black"></GridSplitter>
        <Canvas Grid.Row="0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Background="AliceBlue"></Canvas>
        <Canvas Grid.Row="2" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Background="Yellow"></Canvas>
</Grid>
</Window>