WPF/Silverlight:防止滚动条上的 ScaleTransform
我想知道是否有一种方法可以将 ScaleTransform 应用于 ScrollViewer 并且不允许缩放滚动条。
这是我尝试过的:
<Window x:Class="Zoom.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">
<Window.Resources>
<ScaleTransform x:Key="ScrollBarTransform" ScaleX="1.0" ScaleY="1.0" />
<Style TargetType="ScrollBar">
<Setter Property="LayoutTransform" Value="{StaticResource ScrollBarTransform}" />
</Style>
</Window.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<ScrollViewer Grid.Row="0">
<ScrollViewer.LayoutTransform>
<ScaleTransform ScaleX="{Binding ElementName=scaleSlider, Path=Value}"
ScaleY="{Binding ElementName=scaleSlider, Path=Value}" />
</ScrollViewer.LayoutTransform>
</ScrollViewer>
<Slider Grid.Row="1" Name="scaleSlider" Value="1" Minimum="0.5" Maximum="5.0" TickFrequency="0.25" />
</Grid>
来回移动滑块时,ScrollBarTransform 似乎不会粘住。有什么想法吗?
提前致谢。
I'm wondering if there's a way to apply a ScaleTransform to a ScrollViewer and not allow the scrollbars to be scaled.
Here's what I've tried:
<Window x:Class="Zoom.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">
<Window.Resources>
<ScaleTransform x:Key="ScrollBarTransform" ScaleX="1.0" ScaleY="1.0" />
<Style TargetType="ScrollBar">
<Setter Property="LayoutTransform" Value="{StaticResource ScrollBarTransform}" />
</Style>
</Window.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<ScrollViewer Grid.Row="0">
<ScrollViewer.LayoutTransform>
<ScaleTransform ScaleX="{Binding ElementName=scaleSlider, Path=Value}"
ScaleY="{Binding ElementName=scaleSlider, Path=Value}" />
</ScrollViewer.LayoutTransform>
</ScrollViewer>
<Slider Grid.Row="1" Name="scaleSlider" Value="1" Minimum="0.5" Maximum="5.0" TickFrequency="0.25" />
</Grid>
The ScrollBarTransform doesn't seem to stick when moving the slider back and forth. Any thoughts?
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看来没有办法做我正在寻找的事情。如果我遇到正确的方法,我会更新这个答案。
It appears there isn't a way to do what I'm looking for. If I ever come across the proper method I will update this answer.
为什么不将 ScaleTransform 添加到 ScrollViewer 的内容而不是 ScrollViewer 中?
Why not add your ScaleTransform to the ScrollViewer's content instead of the ScrollViewer?