WPF - 选项卡中的 xaml 滚动条
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15516241/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
WPF - xaml Scrollbar in a tab
提问by Silentdarkness
I wish to implement a scroll bar in a tab here is the following tab code i have:
我希望在选项卡中实现滚动条,这是我拥有的以下选项卡代码:
<TabControl x:Name="tabs"
Grid.Column="2"
Margin="5 0">
<TabControl.LayoutTransform>
<ScaleTransform ScaleX="{Binding ElementName=zoomSlider,
Path=Value}"
ScaleY="{Binding ElementName=zoomSlider,
Path=Value}" />
</TabControl.LayoutTransform>
</TabControl>
However i know it is a scalable tab using a slider, but all i want is the scroll bar to display as another option instead of scaling the page all the time just for usability.
但是我知道它是一个使用滑块的可扩展选项卡,但我想要的只是将滚动条显示为另一个选项,而不是为了可用性而一直缩放页面。
here is the code i have with the scroll bar implemented but it doesn't display.
这是我实现了滚动条的代码,但它没有显示。
<TabControl x:Name="tabs"
Grid.Column="2"
Margin="5 0"
ScrollViewer.VerticalScrollBarVisibility="Auto">
<TabControl.LayoutTransform>
<ScaleTransform ScaleX="{Binding ElementName=zoomSlider,
Path=Value}"
ScaleY="{Binding ElementName=zoomSlider,
Path=Value}" />
</TabControl.LayoutTransform>
</TabControl>
im pretty sure by adding the code: ScrollViewer.VerticalScrollBarVisibility="Auto" it should work?
我很确定通过添加代码:ScrollViewer.VerticalScrollBarVisibility="Auto" 它应该可以工作吗?
Any help would be greatly appreciated.
任何帮助将不胜感激。
回答by sa_ddam213
You will have to wrap the TabControlin a ScrollVieweras TabControldoes not have a ScrollViewerby default
您必须将 a 包裹起来TabControl,ScrollViewer因为默认情况下TabControl没有 aScrollViewer
<ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto">
<TabControl x:Name="tabs" Grid.Column="2" Margin="5 0" >
<TabControl.LayoutTransform>
<ScaleTransform ScaleX="{Binding ElementName=zoomSlider, Path=Value}"
ScaleY="{Binding ElementName=zoomSlider, Path=Value}" />
</TabControl.LayoutTransform>
</TabControl>
</ScrollViewer>
Result:
结果:



