■ ScaleTransform 엘리먼트를 사용해 좌우대칭 반사 텍스트를 만드는 방법을 보여준다.
▶ MainWindow.xaml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
<Window x:Class="TestProject.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" Width="800" Height="600" Title="ScaleTransform 엘리먼트 : 좌우대칭 반사 텍스트 만들기" FontFamily="나눔고딕코딩" FontSize="16"> <Canvas> <Canvas.Resources> <FontFamily x:Key="FontFamilyKey">Times New Roman</FontFamily> <s:Double x:Key="FontSizeDoubleKey">96</s:Double> <TransformGroup x:Key="TransformGroupKey"> <ScaleTransform ScaleX="{Binding Source={StaticResource FontFamilyKey}, Path=Baseline}" /> <ScaleTransform ScaleX="{StaticResource FontSizeDoubleKey}" /> </TransformGroup> <Style TargetType="{x:Type TextBlock}"> <Setter Property="FontFamily" Value="{StaticResource FontFamilyKey}" /> <Setter Property="FontSize" Value="{StaticResource FontSizeDoubleKey}" /> <Setter Property="Text" Value="Reflect" /> <Setter Property="Canvas.Left" Value="384" /> <Setter Property="Canvas.Top" Value="48" /> </Style> </Canvas.Resources> <TextBlock /> <TextBlock> <TextBlock.RenderTransform> <ScaleTransform ScaleX="-1" /> </TextBlock.RenderTransform> </TextBlock> <TextBlock> <TextBlock.RenderTransform> <ScaleTransform ScaleY="-1" CenterY="{Binding Source={StaticResource TransformGroupKey}, Path=Value.M11}" /> </TextBlock.RenderTransform> </TextBlock> <TextBlock> <TextBlock.RenderTransform> <ScaleTransform ScaleX="-1" ScaleY="-1" CenterY="{Binding Source={StaticResource TransformGroupKey}, Path=Value.M11}" /> </TextBlock.RenderTransform> </TextBlock> </Canvas> </Window> |