【发布时间】:2012-03-23 11:56:12
【问题描述】:
重现问题: 垃圾邮件(例如),直到您开始点击正确的网格分割器区域。 gridsplitter 被移动超过右侧最小宽度限制。
预期行为:在文本框中输入(类型/粘贴)时超出宽度限制不会移动网格分割器,但会立即激活滚动条。
条件
- TextBox 必须可以水平和垂直滚动
- TextBox 和 ScrollViewer 必须保持动态大小 - 没有最大宽度限制。这是因为在实际应用程序中,用户可以调整应用程序的大小,这会导致文本框被调整大小。
代码:
<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="350" Width="525">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="10000*" MinWidth="25"/>
<ColumnDefinition Width="8" />
<ColumnDefinition Width="*" MinWidth="25" />
</Grid.ColumnDefinitions>
<ScrollViewer HorizontalScrollBarVisibility="Visible">
<TextBox AcceptsReturn="True" AcceptsTab="True" TextWrapping="Wrap" />
</ScrollViewer>
<GridSplitter Background="Black"
BorderBrush="White"
BorderThickness="1,0,0,0"
ResizeDirection="Columns"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch" Grid.Column="1" />
<Grid Background="Red" Grid.Column="2" />
</Grid>
【问题讨论】: