Why do WPF storyboards lock/freeze target properties?
-
Hi everyone. I might be missing something obvious, but after I run a simple WPF storyboard to animate an object's width, I am no longer able to change the width manually. I have created the simple example below to demonstrate my point. The width change done by the first button works before you animate with the second button, but not after. What am I missing here? How can I "unfreeze" my width property so I can set it again? XAML:
<Canvas>
<Button Click="Button_Click">
Set width to 100
</Button><Button Canvas.Top="30" Animate width to 250 <Button.Triggers> <EventTrigger RoutedEvent="Button.Click"> <BeginStoryboard> <Storyboard> <DoubleAnimation Storyboard.TargetName="RedRectangle" Storyboard.TargetProperty="Width" To="250" Duration="0:0:1" /> </Storyboard> </BeginStoryboard> </EventTrigger> </Button.Triggers> </Button> <Rectangle Name="RedRectangle" Width="25" Height="25" Canvas.Top="70" Fill="Red" Stroke="Black" />
</Canvas>
C# code behind:
private void Button_Click(object sender, RoutedEventArgs e)
{
RedRectangle.Width = 100;
}Thanks in advance
Josh Fischer
-
Hi everyone. I might be missing something obvious, but after I run a simple WPF storyboard to animate an object's width, I am no longer able to change the width manually. I have created the simple example below to demonstrate my point. The width change done by the first button works before you animate with the second button, but not after. What am I missing here? How can I "unfreeze" my width property so I can set it again? XAML:
<Canvas>
<Button Click="Button_Click">
Set width to 100
</Button><Button Canvas.Top="30" Animate width to 250 <Button.Triggers> <EventTrigger RoutedEvent="Button.Click"> <BeginStoryboard> <Storyboard> <DoubleAnimation Storyboard.TargetName="RedRectangle" Storyboard.TargetProperty="Width" To="250" Duration="0:0:1" /> </Storyboard> </BeginStoryboard> </EventTrigger> </Button.Triggers> </Button> <Rectangle Name="RedRectangle" Width="25" Height="25" Canvas.Top="70" Fill="Red" Stroke="Black" />
</Canvas>
C# code behind:
private void Button_Click(object sender, RoutedEventArgs e)
{
RedRectangle.Width = 100;
}Thanks in advance
Josh Fischer
Found the answer to my own question: FillBehavior="Stop" http://msdn.microsoft.com/en-us/library/aa970493.aspx
Josh Fischer
modified on Wednesday, December 10, 2008 10:23 AM
-
Found the answer to my own question: FillBehavior="Stop" http://msdn.microsoft.com/en-us/library/aa970493.aspx
Josh Fischer
modified on Wednesday, December 10, 2008 10:23 AM
Thank you! Phil