如果wpf应用程序为窗口设置了UseLayoutRounding为true,那么网格分割器将不再适用于某些窗口宽度(它会卡在原始位置),如下面的示例。WPF Gridsplitter不能与UseLayoutRounding一起使用
<Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="200" Width="401"
UseLayoutRounding="True">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0">
long string that does not fit within the textblock - long string that does not fit within the textblock
</TextBlock>
<GridSplitter Grid.Column="1" HorizontalAlignment="Center" Width="50" Background="LightBlue" />
<TextBlock Grid.Column="2">
long string that does not fit within the textblock - long string that does not fit within the textblock
</TextBlock>
</Grid>
</Window>
注意,对于例如产生错误的窗口宽度必须是401,在文本框的文本必须长于文本框和UseLayoutRounding必须是真实的。
任何知道如何避免这种情况或有任何解决方法?我不想将UseLayoutRounding设置为false,因为它会在我的应用程序中导致渲染工件。
编辑: 对于其他有同样的问题,我发现这个用户做出组件解决了这个问题:http://blog.onedevjob.com/2011/12/11/fixing-wpf-gridsplitter/仍然会是很好的,如果它可以用默认的WPF成分虽然可以解决。
感谢您的响应,它并没有真正的工作,它只是改变什么窗口宽度分离器卡住了。上面代码的窗口宽度为403将仍然会生成错误。 – GulPaprika 2015-02-12 20:21:59