チェックボックスを介して変換を有効にしたい。
私のサンプルでは、ラベルのテキストをそれぞれ x または y 方向に入れ替える 2 つのチェックボックスがあります。
これはコードビハインドなしで可能ですか?
これまでの私のxamlは次のとおりです。
<Window x:Class="WpfVideoTest.InversionTestWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="InversionTestWindow" Height="300" Width="300">
<DockPanel>
<CheckBox DockPanel.Dock="Bottom" IsChecked="{Binding InvertX}">Invert X</CheckBox>
<CheckBox DockPanel.Dock="Bottom" IsChecked="{Binding InvertY}">Invert Y</CheckBox>
<Label Content="Text to invert" FontSize="40" x:Name="TextToInvert">
<Label.RenderTransform>
<TransformGroup>
<!-- transformations to swap in x direction -->
<ScaleTransform ScaleX="-1" />
<TranslateTransform X="{Binding ActualWidth, ElementName=TextToInvert}" />
<!-- transformations to swap in y direction -->
<ScaleTransform ScaleY="-1" />
<TranslateTransform Y="{Binding ActualHeight, ElementName=TextToInvert}" />
</TransformGroup>
</Label.RenderTransform>
</Label>
</DockPanel>