2011-01-03 6 views
1

私は同じスタイルを使いたいので、私はResourceDictionaryで通常/無効/有効状態のいくつかの勾配ブラシを作成しました。 "ButtonFillBrush"、 "ButtonFillMouseOverBrush"などです。これらはグローバルな再利用可能なBrush Resourcesとして定義されています。Silverlight:状態アニメーションにGradientBrushリソースを使用します。

私は例えば、状態内部のアニメーションで勾配の個々の停止を変更することが可能である知っている:

<VisualState x:Name="MouseOver"> 
    <Storyboard> 
     <ColorAnimation Duration="0" To="#FF041D06" Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[1].(GradientStop.Color)" Storyboard.TargetName="path" d:IsOptimized="True"/> 
     <ColorAnimation Duration="0" To="#FF118519" Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[0].(GradientStop.Color)" Storyboard.TargetName="backgroundRectangle" d:IsOptimized="True"/> 
    </Storyboard> 
</VisualState> 

は今、私はそれはのような何かをするvisualSTATEのマネージャーで可能です知っている:

<VisualState x:Name="MouseOver"> 
    <Storyboard> 
     <ColorAnimation Duration="0" To="ButtonFillMouseOverBrush" Storyboard.TargetProperty="(Shape.Fill).(GradientBrush)" Storyboard.TargetName="backgroundRectangle" d:IsOptimized="True"/> 
    </Storyboard> 
</VisualState> 

ありがとうございました!

更新:StaticResourceといくつかのより多くの検索と参照についての答えを使用して:http://wildermuth.com/2008/07/18/Animating_Brushes_with_ObjectAnimationUsingKeyFrames

<VisualState x:Name="MouseOver"> 
    <Storyboard> 
    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="backgroundRectangle"      
Storyboard.TargetProperty="Fill"> 
     <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="{StaticResource ButtonFillMouseOverBrush}" /> 
    </ObjectAnimationUsingKeyFrames> 
    </Storyboard> 
</VisualState> 

だから、BrushAnimationか何かを持っていいだろう...

ロジェ

答えて

0

リソースディクショナリ&の詳細については、hereの使用を参照してください。しかし、あなたのカラーアニメーションの質問のために、このリンクでSilverlightアニメーション(カラーアニメーションを含む)に関する多くの情報を見つけることができます。Silverlight Animations Quickstart

+0

こんにちはNiels、ブラシの代わりに色が必要なので、これはうまくいきません。しかし、StaticResourceについてのビットは正しい答えを見つけるのを助けてくれたので、私の編集 – Rogier

+0

Heheあなたはちょうど私が推測する辞書の色でブラシを交換することができます。私は最近、Windows Phone用のSilverlightを使い始めたので、私の知識はかなり限られています。あなたはそれを考え出してうれしい! – Citroenfris

+0

私の回答が更新されました。 – Citroenfris

関連する問題