我有以下测试样本:
<Window x:Class="WpfScrollTest.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="200" Width="200">
<Border>
<StackPanel>
<Label Width="Auto" Height="Auto" Content="Text to mess up the scrollview"/>
<ScrollViewer Height="{Binding RelativeSource={RelativeSource FindAncestor,
AncestorType={x:Type Border}}, Path=ActualHeight}">
<StackPanel>
<Button MinWidth="100" MinHeight="100" Content="Button"/>
<Button MinWidth="100" MinHeight="100" Content="Button"/>
</StackPanel>
</ScrollViewer>
</StackPanel>
</Border>
</Window>
这创造了这个:
我的问题是如何ScrollViewer.Height
在仍然能够看到滚动条底部的同时动态设置?在我的示例中,由于上面Height
的ScrollViewer
原因太长了..Label
我不想将 的 修复Height
为ScrollViewer
静态值。