What is the behavior of the WPF 4 trigger ControlStoryboardAction?

I have a question that has been bugging me for a while:

I have a long I / O operation that I am calling asynchronously and I want my UI to display flashing text to inform users that data is loading.

I have an IsLoading boolean property in my ViewModel and I have used a ControlStoryboardAction to trigger a flashing animation that is set to repeat forever. For my ControlStoryboardAction trigger, I set up a data trigger to see if IsLoading is true, and fire my storyboard if true.

My problem is, when my I / O operation returns and I set IsLoading back to false, the animation keeps playing. I thought that when the trigger condition evaluates to false, will it stop the animation?

Then I added a second ControlStoryboardAction to stop the animation if IsLoading is changed to false, but it had no effect. The animation kept playing after IsLoading was false.

Can anyone explain to me how the trigger works in the ControlStoryboardAction? In normal data triggers in WPF, as soon as a condition evaluates to false, the property will be reset to its original state. Triggers in WPF actions seem to work wrong?

+2


a source to share


1 answer


Generally speaking, a DataTrigger

will revert properties back to their previous value when the specified condition ceases to be true.

The same goes for actions. There is no way for a trigger to know which action will "undo" the action of the triggered action, assuming that even such an action exists.



I think you want to define another trigger in the opposite state (for example, using a boolean-not converter on IsLoading, adding an IsNotLoading property, etc.) that fires "Stop" ControlStoryboardAction

.

0


a source







All Articles