Skip to main content
Home Forums Silverlight Programming Programming with .NET - General Binding the From and To properties of an animation in XAML
3 replies. Latest Post by coryking on August 17, 2008.
(0)
atm_grifter
Member
8 points
28 Posts
08-07-2008 4:26 PM |
I have a UserControl that defines a VisualState in XAML where I would like to bind the From and To properties of the DoubleAnimation to properties of the UserControl. Is this possible? I can create the Storyboard just fine in the code-behind, but I don't know if I can create those same bindings in the XAML of the UserControl.
Example:
<UserControl x:Class="MyUserControl"> <Grid> <VisualState> <StoryBoard> <DoubleAnimation From="{Binding Prop1}" To="{Binding Prop2}" etc.../>
...
public class MyUserControl : UserControl{ public Double Prop1 {get; set;} public Double Prop2 {get; set;}}
When I run this I get an exception in the XAML parser.
08-07-2008 5:17 PM |
So I misspoke. Bindings are the wrong approach here, however the spirit of what I'm trying to do remains, which is to set the 'From' property of an animation to a property that exists on the UserControl in XAML. I understand why bindings wouldn't work as you can't call SetBinding on an animation object.
Unless I'm missing something, there isn't a way to do this in either Silverlight or WPF correct?
Allen Ch...
Star
13862 points
1,803 Posts
08-14-2008 4:09 AM |
Hi
atm_grifter:Unless I'm missing something, there isn't a way to do this in either Silverlight or WPF correct?
It can be done in WPF but unfortunately in Silverlight binding can only be set on FrameworkElement or it's descendent class.
coryking
40 points
17 Posts
08-17-2008 6:41 PM |
Hello Allen,
Allen Chen – MSFT:It can be done in WPF but unfortunately in Silverlight binding can only be set on FrameworkElement or it's descendent class.