无法理解为什么Translatetransform
绑定不起作用。我有 3 个滑块 - 一个用于缩放,2 个用于 x 和 y 变换(我有圆圈作为Canvas
代码中的子元素)。
我在 XAML 下面使用:
<Window x:Class="Visualizer.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" WindowState="Maximized" WindowStartupLocation="CenterScreen" ResizeMode="NoResize">
<Canvas HorizontalAlignment="Stretch" Margin="0,0,0,0" VerticalAlignment="Stretch" Name="MainCanvas" >
<Canvas HorizontalAlignment="Stretch" Margin="0,0,0,0" VerticalAlignment="Stretch" Name="OperatorsCanvas" >
<ContentControl x:Name="OperatorsContent"/>
<Canvas.LayoutTransform>
<TransformGroup>
<ScaleTransform
CenterX="0"
CenterY="0"
ScaleX="{Binding ElementName=ScaleSlider,Path=Value}"
ScaleY="{Binding ElementName=ScaleSlider,Path=Value}"
/>
<TranslateTransform X="{Binding ElementName=TranslateXSlider,Path=Value}" Y="{Binding ElementName=TranslateYSlider,Path=Value}" />
</TransformGroup>
</Canvas.LayoutTransform>
</Canvas>
<Slider Canvas.Right="5" Width="154" Canvas.Top="5" HorizontalAlignment="Right" Name="ScaleSlider" ToolTip="Determines the UI scale factor."
Value="1" Minimum="0.1" Maximum="4"/>
<Slider Canvas.Bottom="0" Width="762" HorizontalAlignment="Stretch" Name="TranslateXSlider" Value="0" Minimum="-20" Maximum="20"/>
<Slider Canvas.Right="0" Canvas.Top="282" Width="423" RenderTransformOrigin="0.494,0.455" Height="16" Name="TranslateYSlider" Value="0" Minimum="-20" Maximum="20" >
<Slider.RenderTransform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform/>
<RotateTransform Angle="90"/>
<TranslateTransform/>
</TransformGroup>
</Slider.RenderTransform>
</Slider>
</Canvas>
</Window>
缩放有效,但变换无效。