VerticalAlignment=“拉伸”从我的容器中伸出
我有一个父容器,用于保存所有用户控件。问题是我使用 VerticalAlignment="Stretch"
将内容拉伸到完整高度并获得垂直滚动条,用户控件被拉伸太多。出现垂直滚动条但无法滚动。我知道这一点是因为滚动条的向下箭头不可见。
我有
,可以在其中分配各种控件。例如,下面的 XAML 在拉伸方面不起作用。
<StackPanel>
<TextBlock Text="{Binding FoundCount}" FontSize="13" Foreground="#666" Margin="0 0 0 8" />
<ScrollViewer VerticalAlignment="Stretch">
<TreeView
ItemsSource="{Binding Listing}"
Grid.Row="1"
BorderThickness="0"
VirtualizingStackPanel.IsVirtualizing="True" />
</ScrollViewer>
</StackPanel>
我只想让 TreeView
拉伸并显示垂直滚动条。
有什么想法吗?
I have a parent container that is used to hold all of my user controls. The issue is that I use VerticalAlignment="Stretch"
to stretch contents to the full height and get a vertical scroll bar the user control gets stretched too much. The vertical scrollbar appears but there is no way to scroll. I know this because the down arrow for the scroll bar isn't visible.
I have <ContentControl Content="{Binding Workspace}" />
which is where a variety of controls can be assigned. For example, here is the XAML that is not working property in regards to stretching.
<StackPanel>
<TextBlock Text="{Binding FoundCount}" FontSize="13" Foreground="#666" Margin="0 0 0 8" />
<ScrollViewer VerticalAlignment="Stretch">
<TreeView
ItemsSource="{Binding Listing}"
Grid.Row="1"
BorderThickness="0"
VirtualizingStackPanel.IsVirtualizing="True" />
</ScrollViewer>
</StackPanel>
I only want to the TreeView
to stretch and display a vertical scrollbar.
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我怀疑 StackPanel 的高度不受限制,因此它会增长以容纳 ScrollViewer。您可以通过在 StackPanel 上添加边框来检查这一点。
I suspect the height of the StackPanel is not contrained so it grows to accomodate the ScrollViewer. You can check this by putting a border on the StackPanel.