wpf - How to animate a resource in XAML? -


In the XAML document, I have a gradient brush as a resource and there is a bunch of shapes using this resource.

I want to animate the brush using the storyboard, but to set the brush in resources as the goal of the storyboard I do not know about just using its name does not work, {StaticResource name} does not even work, is it even possible?

I would like an XML solution, but if this will not work, I will use the code-back. If this lets me leave the storyboard Goals and storyboards Target unassigned targeting.

EDIT: I want to animate a gradient stop of the brush. The thing is that I can animate it easily when there is no resource, but is applied directly to one object, I can do this by clicking on the expression blend. I do not know how to change a consciousness when its resources (ie what is kept instead of the code in the code below) (the storyboard was made for the rectangle))

  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" /> & Lt; GradientStop color = "# 7F047695" offset = "1" /> & Lt; GradientStop color = "#FFFFFFFF" offset = "0.942" /> & Lt; / LinearGradientBrush & gt; & Lt; Storyboard x: key = "luster" & gt; & Lt; Double animation tool keyframe start time = "00:00:00" storyboard. Target = "??" Storyboard.TargetProperty = "(Shape.Fill) (GradientBrush.GradientStops) [0] (GradientStop.Offset) .." & Gt; & Lt; Time of SplineDoubleKeyFrame = "00:00:00" value = "0" /> & Lt; SplineDoubleKeyFrame Keytime = "00: 00: 02.6000000" value = "0.529" /> & Lt; / DoubleAnimationUsingKeyFrames & gt; & Lt; / Storyboard & gt; ...  

This works when you have a basic form of background / fill property Let's name the object (like rectangle) you want to animate in the form of storyboards. TargetName:

  & lt; Window x: orbit = "wpfApplication1.Window1" xmlns = "http://schemas.microsoft com / winfx / 2006 / xaml / presentation" xmlns: x = "http://schemas.microsoft.com/winfx/2006/xaml "Title =" window 1 "height =" 300 "width =" 300 "& gt; & Lt; Grid & gt; & Lt; Grid.Resources & gt; & Lt; LinearGradientBrush x: key = "outline" endpoint = "0.5,1" startpoint = "0.5,0" & gt; & Lt; GradientStop color = "# 7F7CE3FF" offset = "0" /> & Lt; GradientStop color = "# 7F047695" offset = "1" /> & Lt; GradientStop color = "#FFFFFFFF" offset = "0.942" /> & Lt; / LinearGradientBrush & gt; & Lt; /Grid.Resources> & Lt; Border name = "border" background = "{external line of static resources}" width = "200" height = "200" /> & Lt; / Grid & gt; & Lt; Window.Triggers & gt; & Lt; Event Trigger Routing Avent = "Window Loaded" & gt; & Lt; BeginStoryboard & gt; & Lt; Storyboard & gt; & Lt; Frame initial time using double animation = "00:00:00" Storyboard. Target name = "border" storyboard Targetproperty = "(border background). (GradientBrush.GradientStops) [0]. (GradientStop.Offset)" & gt; & Lt; Time of SplineDoubleKeyFrame = "00: 00: 0" value = "0" /> & Lt; Time of SplineDoubleKeyFrame = "00: 00: 1" value = "1" /> & Lt; / DoubleAnimationUsingKeyFrames & gt; & Lt; / Storyboard & gt; & Lt; / BeginStoryboard & gt; & Lt; / EventTrigger & gt; & Lt; /Window.Triggers>  

Edit

The code behind it is entirely possible:

< P> XAM:

  & lt; Grid name = "grid" & gt; & Lt; Grid.Resources & gt; & Lt; LinearGradientBrush x: key = "outline" endpoint = "0.5,1" startpoint = "0.5,0" & gt; & Lt; GradientStop color = "# 7F7CE3FF" offset = "0" /> & Lt; GradientStop color = "# 7F047695" offset = "1" /> & Lt; GradientStop color = "#FFFFFFFF" offset = "0.942" /> & Lt; / LinearGradientBrush & gt; & Lt; /Grid.Resources> & Lt; Border background = "{external line of static resources}" width = "100" height = "100" horizontal align = "left" /> & Lt; Border background = "{outline of static resources}" width = "100" height = "100" horizontal alignment = "right" /> & Lt; / Grid & gt;  

Back C # code:

  Linear GradientBrash B = Grid. Resources ["Outline"] as LinearGradientBrush; B.GradientStops [0] .Bininification (GradientStop.OffsetProperty, New DoubleAnimation (0, 1, New Duration (Timespace: FormsCondus (1))));  

Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -