wpf-storyboardでスクロール中アニメーションを作る
10567 ワード
スクロールビューワでスクロール中に出現するアニメーションを作成。
実際はこれをRenderTransformでスクロール方向に回転させたりして使う。
コードは下記
<UserControl x:Class="ScrollingTriangleTest.ScrollingTriangle"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:ScrollingTriangleTest"
mc:Ignorable="d">
<UserControl.Resources>
<Storyboard x:Key="FlashStyle1">
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" RepeatBehavior="Forever">
<LinearDoubleKeyFrame KeyTime="0:0:0.0" Value="0"/>
<LinearDoubleKeyFrame KeyTime="0:0:0.2" Value="0.8"/>
<LinearDoubleKeyFrame KeyTime="0:0:0.4" Value="0.8"/>
<LinearDoubleKeyFrame KeyTime="0:0:0.6" Value="0.8"/>
<LinearDoubleKeyFrame KeyTime="0:0:1" Value="0"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
<Storyboard x:Key="FlashStyle2">
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" RepeatBehavior="Forever">
<LinearDoubleKeyFrame KeyTime="0:0:0.0" Value="0"/>
<LinearDoubleKeyFrame KeyTime="0:0:0.2" Value="0"/>
<LinearDoubleKeyFrame KeyTime="0:0:0.4" Value="0.8"/>
<LinearDoubleKeyFrame KeyTime="0:0:0.6" Value="0.8"/>
<LinearDoubleKeyFrame KeyTime="0:0:1" Value="0"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
<Storyboard x:Key="FlashStyle3">
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" RepeatBehavior="Forever">
<LinearDoubleKeyFrame KeyTime="0:0:0.0" Value="0"/>
<LinearDoubleKeyFrame KeyTime="0:0:0.2" Value="0"/>
<LinearDoubleKeyFrame KeyTime="0:0:0.4" Value="0"/>
<LinearDoubleKeyFrame KeyTime="0:0:0.6" Value="0.8"/>
<LinearDoubleKeyFrame KeyTime="0:0:1" Value="0"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
<Style x:Key="FlashTriangle3" TargetType="Path">
<Setter Property="Fill" Value="DarkGray"/>
<Style.Triggers>
<EventTrigger RoutedEvent="Path.Loaded">
<BeginStoryboard Storyboard="{StaticResource FlashStyle3}"/>
</EventTrigger>
</Style.Triggers>
</Style>
<Style x:Key="FlashTriangle2" TargetType="Path">
<Setter Property="Fill" Value="DarkGray"/>
<Style.Triggers>
<EventTrigger RoutedEvent="Path.Loaded">
<BeginStoryboard Storyboard="{StaticResource FlashStyle2}"/>
</EventTrigger>
</Style.Triggers>
</Style>
<Style x:Key="FlashTriangle1" TargetType="Path">
<Setter Property="Fill" Value="DarkGray"/>
<Style.Triggers>
<EventTrigger RoutedEvent="Path.Loaded">
<BeginStoryboard Storyboard="{StaticResource FlashStyle1}"/>
</EventTrigger>
</Style.Triggers>
</Style>
</UserControl.Resources>
<Grid>
<StackPanel>
<Path Style="{StaticResource ResourceKey=FlashTriangle3}" Stroke="DarkGray" StrokeThickness="2" Data="M 0,15 L 30,15 L 15,0 Z"/>
<Path Style="{StaticResource ResourceKey=FlashTriangle2}" Stroke="DarkGray" StrokeThickness="2" Data="M 0,15 L 30,15 L 15,0 Z"/>
<Path Style="{StaticResource ResourceKey=FlashTriangle1}" Stroke="DarkGray" StrokeThickness="2" Data="M 0,15 L 30,15 L 15,0 Z"/>
</StackPanel>
</Grid>
</UserControl>
Author And Source
この問題について(wpf-storyboardでスクロール中アニメーションを作る), 我々は、より多くの情報をここで見つけました https://qiita.com/ka26/items/a4df0251df22e991e097著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .