0
は、ここで私はappliction資源私はボタンのテキストに下線矩形を追加したスタイルでWPFスタイルのストーリーボードバリュー
<Style x:Key="ClickableText" TargetType="{x:Type Button}">
<Setter Property="BorderBrush" Value="{x:Null}"/>
<Setter Property="FontFamily" Value="/Tasks;component/Assets/Fonts/#Abel"/>
<Setter Property="Background" Value="Transparent" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Border Background="{TemplateBinding Background}">
<StackPanel VerticalAlignment="Center">
<ContentPresenter x:Name="Text" HorizontalAlignment="Center" VerticalAlignment="Center"/>
<Rectangle x:Name="Rect1" Width="{Binding ActualWidth, ElementName=Text}" Height="2" Fill="{DynamicResource LightGrey}"/>
</StackPanel>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="White"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
でのボタンのスタイルを持っています。
<Rectangle x:Name="Rect1" Width="{Binding ActualWidth, ElementName=Text}" Height="2" Fill="{DynamicResource LightGrey}"/>
矩形の幅をテキストと同じ幅にバインドして、下線効果を追加しました。
ボタンをホバーすると、四角形が分割されて表示されるように、エフェクトを追加します。
私は遠くトリガータグ
<Trigger.EnterActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Duration="0:0:0.300" From="0" To="{Binding ActualWidth, ElementName=Text}" Storyboard.TargetName="Rect1" Storyboard.TargetProperty="Width" />
</Storyboard>
</BeginStoryboard>
</Trigger.EnterActions>
<Trigger.ExitActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Duration="0:0:0.300" From="{Binding ActualWidth, ElementName=Text}" To="0" Storyboard.TargetName="Rect1" Storyboard.TargetProperty="Width" />
</Storyboard>
</BeginStoryboard>
</Trigger.ExitActions>
私は、矩形で使用される結合にすると、二重アニメーションの一部からリンクしたいが、それはエラーを生成し続けるの下にこれを追加することで、これを持っています。この効果をどうやってすることができますか?
私はこれを再利用可能なスタイルとして使用したいので、私は配布してアプリケーションリソースに保管することができます。コード内の回避策によって他の人がこれを行うのを見たことがありますが、アプリケーションリソースでこれを行うことができるかどうかはわかりません。
ヘルプやガイダンスが大幅にアップされました!
一般的に失敗し、回避策が唯一存在し、全体の質問を読んでいないが、基本的には、 'Binding'は非常にStoryBoard'要素'に限定されていますいくつかのプロパティのために。 – grek40
[WPF animation:ストーリーボードアニメーションのTo属性へのバインド]の可能な複製(https://stackoverflow.com/questions/2186933/wpf-animation-binding-to-the-to-attribute-of-storyboard-アニメーション) – grek40