缩放控件到 WPF 表单 [英] Zoom control to WPF Form
本文介绍了缩放控件到 WPF 表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何为我的 wpf 表单实现类似于 Visual Studio 设计器中可用的缩放控件?
How can I implement a zoom control to my wpf forms similar to the one avaialble in the visual studio designer?
谢谢!
推荐答案
把你的东西放到一个网格中,将网格的缩放渲染变换绑定到一个滑块(滑块的最小值应该为 1):
Put your stuff into a grid, bind the grid's scale render transformation to a slider (slider should have min value of 1):
<Grid x:Name="LayoutRoot">
<Grid.RowDefinitions>
<RowDefinition Height="0.867*"/>
<RowDefinition Height="0.133*"/>
</Grid.RowDefinitions>
<Slider x:Name="slider" Grid.Row="1" Minimum="1"/>
<Grid RenderTransformOrigin="0.5,0.5">
<Grid.RenderTransform>
<TransformGroup>
<ScaleTransform
ScaleY="{Binding Path=Value, ElementName=slider}"
ScaleX="{Binding Path=Value, ElementName=slider}"/>
</TransformGroup>
</Grid.RenderTransform>
<TextBox Text="TextBox" Height="45.214"
VerticalAlignment="Top" Margin="194,139,209,0"/>
<TextBox VerticalAlignment="Bottom"
Text="TextBox" Margin="194,0,209,118.254" Height="48.96"/>
</Grid>
</Grid>
这篇关于缩放控件到 WPF 表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文