Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to animate a resource in XAML?
    text
    copied!<p>In an XAML document, I have a gradient brush as a resource and a bunch of shapes that use this resource. I would like to animate the brush using a storyboard, but I don't know how to set the brush in resources as the target of storyboard. Simply using its name does not work, {StaticResource name} does not work either. Is it even possible?</p> <p>I would prefer an XAML only solution, but if that does not work out, I'll use code-behind. If it lets me leave Storyboard.Target and Storyboard.TargetProperty unassigned.</p> <p>EDIT: I would like to animate a gradient stop of the brush. The thing is that I can animate it easily when it's not a resource, but is applied directly on an object. I can do that by clicking in Expression Blend. I just don't know how to animate it when its a resource (i.e. what to put instead of the ?? in the code below (the storyboard was created for a rectangle))</p> <pre><code>code: &lt;UserControl.Resources&gt; &lt;LinearGradientBrush x:Key="Outline" EndPoint="0.5,1" StartPoint="0.5,0"&gt; &lt;GradientStop Color="#7F7CE3FF" Offset="0"/&gt; &lt;GradientStop Color="#7F047695" Offset="1"/&gt; &lt;GradientStop Color="#FFFFFFFF" Offset="0.942"/&gt; &lt;/LinearGradientBrush&gt; &lt;Storyboard x:Key="Glitter"&gt; &lt;DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="??" Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[0].(GradientStop.Offset)"&gt; &lt;SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/&gt; &lt;SplineDoubleKeyFrame KeyTime="00:00:02.6000000" Value="0.529"/&gt; &lt;/DoubleAnimationUsingKeyFrames&gt; &lt;/Storyboard&gt; ... </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload