以下简单的XAML在滚动查看器内的网格底部放置一个边框,并将网格的宽度链接到滑块的值。
<Window x:Class="BorderWidth.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="DrawBorder">
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition Height="50"/>
<RowDefinition Height="50"/>
</Grid.RowDefinitions>
<ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
<Grid Height="100" VerticalAlignment="Top" HorizontalAlignment="Left" Width="{Binding Value, ElementName=slider}">
<Border BorderBrush="Gray" BorderThickness="0,0,0,1"/>
</Grid>
</ScrollViewer>
<TextBox Grid.Row="1" HorizontalAlignment="Center" VerticalAlignment="Center" Text="{Binding Value, ElementName=slider}"/>
<Slider x:Name="slider" Minimum="124000" Maximum="126000" Grid.Row="2" VerticalAlignment="Center" Margin="10"/>
</Grid>
</Window>
当宽度小于125000时,边框会显示,但在该值之后它会消失。 the documentation for the border control中没有提到最大宽度,一般is documented的控件的最大宽度介于Single.MaxValue
和Double.MaxValue
之间,即远远大于125000.是这个125000上限有一个bug;还是在某处记录?