I'm trying to trigger a progress animation when ever the ViewModel/Presentation Model is Busy. I have a IsBusy Property, and the ViewModel is set as the DataContext of the UserControl. What is the best way to trigger a "progressAnimation" story board when the IsBusy property is true? Blend only let med add Event-Triggers on a UserControl level, and I can only create property triggers in my data templates.
The "progressAnimation" is defined as a resource in the user control.
I tried adding the DataTriggers as a Style on the UserControl, but when I try to start the StoryBoard I get the following error:
'System.Windows.Style' value cannot be assigned to property 'Style'
of object'Colorful.Control.SearchPanel'. A Storyboard tree in a Style
cannot specify a TargetName. Remove TargetName 'progressWheel'.
ProgressWheel is the name of the object I'm trying to animate, so removing target name is obvisouly NOT what I want.
I was hoping to solve this in XAML using data binding techniques, in stead of having to expose events and start/stop the animation through code.
Best Answer
What you want is possible by declaring the animation on the progressWheel itself: The XAML:
Code behind:
The viewmodel:
Hope this helps!