开发者

WPF: Storyboard set property overrides code behind?

开发者 https://www.devze.com 2023-01-12 10:36 出处:网络
I\'m working on a wpf c# app and I have a question. I have a storyboard which at the end sets the property of a grid to Visibility.Visible.

I'm working on a wpf c# app and I have a question. I have a storyboard which at the end sets the property of a grid to Visibility.Visible. Now on my code behind when I try to set the vis开发者_Go百科ibility to hidden again after the storyboard has run, the visibility won't change!

Is the storyboard still running somehow or is a storyboard set property a fixed property after running the storyboard?


I believe you need to set FillBehavior property:

 <Storyboard FillBehavior="Stop">


The storyboard is still running. I ran into the same thing myself, where I wanted to run a storyboard when a button was clicked but also to have it re-run from the original state. Setting FillBehavior property to Stop works in this case. However, if you want to keep the end state of the animation until the user clicks the button again, you can't use it. All I did was to stop the storyboard, then set the Visible properties and that solved my problem. Until I actually called Stop() the values were always overridden. This would also explain why when I set properties that the storyboard wasn't modifying (such as color, etc) I had no problem.

0

精彩评论

暂无评论...
验证码 换一张
取 消