ButtonをDataTriggerをTriggerとしてBlinkさせたい
ボタンブリンク自体がサンプルすくねーよ!しかもサンプルがあってもClickイベント拾ってるよ!!な状態だったので、非常に助かりました。
stackoverflow.com
最終的なコードはこれ。
<Window.Resources> <Style x:Key="ButtonStyle" TargetType="{x:Type Button}"> <Setter Property="Background"> <Setter.Value> <SolidColorBrush Color="Transparent"/> </Setter.Value> </Setter> <Style.Triggers> <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=Window}, Path=DataContext.Notification}" Value="True"> <DataTrigger.EnterActions> <BeginStoryboard Name="StartBlinking"> <Storyboard> <ColorAnimation Storyboard.TargetProperty="(Background).(SolidColorBrush.Color)" To="Orange" Duration="00:00:00.4" RepeatBehavior="Forever" AutoReverse="True"/> </Storyboard> </BeginStoryboard> </DataTrigger.EnterActions> </DataTrigger> <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=Window}, Path=DataContext.Notification}" Value="False"> <DataTrigger.EnterActions> <RemoveStoryboard BeginStoryboardName="StartBlinking"/> </DataTrigger.EnterActions> </DataTrigger> </Style.Triggers> </Style>
ポイントはここ
<RemoveStoryboard BeginStoryboardName="StartBlinking"/>
いったん開始したStoryBoadを削除(Remove)しなくちゃ次始められないのね。
ふむむ。
結局のところ
が書かれてないけど、
(時間があれば調べる)