이와 같은 작업을 수행하는 주요 기능은 OpacityMask입니다. 아래의 예제는 마스크를 위해 Tile로 설정된 VisualBrush를 사용하고 브러시의 transform 속성을 사용하여 설명 된 동작을 수행합니다.
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" x:Class="WpfApplication1.MainWindow"
Title="MainWindow" Height="447" Width="569">
<Window.Resources>
<Storyboard x:Key="Wave">
<DoubleAnimation Storyboard.TargetProperty="(UIElement.OpacityMask).(Brush.RelativeTransform).(TransformGroup.Children)[3].(TranslateTransform.X)" Storyboard.TargetName="ellipse" RepeatBehavior="Forever" From="0" To="1" Duration="0:0:1" />
</Storyboard>
</Window.Resources>
<Window.Triggers>
<EventTrigger RoutedEvent="FrameworkElement.Loaded">
<BeginStoryboard Storyboard="{StaticResource Wave}"/>
</EventTrigger>
</Window.Triggers>
<Canvas>
<Ellipse x:Name="ellipse" Fill="#FF82C6FF" Height="160" Canvas.Left="320" Canvas.Top="80" Width="160">
<Ellipse.OpacityMask>
<VisualBrush Visual="{Binding ElementName=wave}" TileMode="Tile" Viewport="0,-1,1,3" Stretch="None" >
<VisualBrush.RelativeTransform>
<TransformGroup>
<ScaleTransform />
<SkewTransform/>
<RotateTransform/>
<TranslateTransform Y="{Binding Value,ElementName=y}" />
</TransformGroup>
</VisualBrush.RelativeTransform>
</VisualBrush>
</Ellipse.OpacityMask>
</Ellipse>
<Grid x:Name="wave" Height="377" Canvas.Left="80" Canvas.Top="23" Width="160" Background="#00000000">
<Grid.RowDefinitions>
<RowDefinition Height="1*"/>
<RowDefinition Height="{Binding Value,ElementName=amplitude}"/>
<RowDefinition Height="1*"/>
</Grid.RowDefinitions>
<Path Fill="#FF82C6FF" Data="M12.5,1.6925709 C31.25,1.6925709 31.25,18.615654 50,18.615654 68.75,18.615654 68.75,1.6925709 87.5,1.6925709 87.499909,27.077196 87.5,27.077107 87.5,27.077107 63.28125,27.077136 12.5,27.077196 12.5,27.077196 12.5,27.077196 12.500094,27.077196 12.5,1.6925709 z" Stretch="Fill" Grid.Row="1"/>
<Rectangle Fill="#FF82C6FF" Grid.Row="2" Margin="0,-1,0,0" />
</Grid>
<Slider x:Name="y" Width="200" Minimum="-0.6" Maximum="1" Value="0"/>
<Slider x:Name="amplitude" Width="200" Minimum="1" Maximum="100" Value="20" Canvas.Top="23"/>
</Canvas>
</Window>
마스크를 숨기려면 위의 바인딩 대신 VisualBrush에 직접 배치 할 수 있습니다. 다른 유형의 브러시와 해당 변형 및 뷰포트/뷰 박스를 살펴볼 수도 있습니다.
업데이트 : 마스크가 두 조각으로되어있어 웨이브 진폭을 별도로 조정할 수 있습니다. ScaleTransform.ScaleX
을 조정하여 빈도를 변경할 수도 있지만 전체 웨이브 또는 애니메이션이 더 이상 들리지 않도록 시도해야합니다 (예 : 시도) 0.5,0.25,0.1
와우! 대단한 직업! 당신에게 충분히 감사 할 수 없다! !! – Tokfrans
한 가지. 어떻게 파도의 진폭을 줄이시겠습니까? 저는 경로 구문을 잘 이해하지 못했고 실제로 이것을 이해할 수 없습니다 – Tokfrans
Expression Blend에서 모양을 그렸습니다. 시도 할 대안 경로를 추가하겠습니다. – Kris