xaml - Trying to begin a storyboard on change of a property in WPF application -
i have simple mvvm application. contains property, change true when method correctly executes, , false if now. when property changes, few seconds display "passed" or "failed" on status bar of wpf application , have fade away.
so have read stackoverflow, , googled intensely, no avail. think have misunderstood how need structure storyboard.
in statusbar have added storyboard, trying trigger in <usercontrol.resources>
@ beginning of xaml file. correct ? @ moment using dummy values of 0/1, assume correct practice use booleantostring converter make, or perhaps there better way?
so status bar contains :
<statusbar > <statusbar.resources> <storyboard x:key="statusbar" > <doubleanimationusingkeyframes storyboard.targetproperty="(uielement.opacity)" storyboard.targetname="statusbaritem"> <easingdoublekeyframe keytime="0" value="0"/> <easingdoublekeyframe keytime="0:0:0.5" value="1"/> <easingdoublekeyframe keytime="0:0:3" value="1"/> <easingdoublekeyframe keytime="0:0:4" value="0"/> </doubleanimationusingkeyframes> </storyboard> </statusbar.resources> </statusbar>
and trying register called in usercontrol.resources :
do have structure backwards ? not compile , error :
a value of type 'beginstoryboard' cannot added collection or dictionary of type 'setterbasecollection'.
any help, resources or information appreciated. lot.
here's example. need use trigger start storyboard.
<grid> <grid.datacontext> <wpfapplication1:mainviewmodel/> </grid.datacontext> <grid.resources> <style x:key="statusstyle" targettype="statusbar"> <setter property="opacity" value="0"/> <style.triggers> <datatrigger binding="{binding pulse}" value="true"> <datatrigger.enteractions> <beginstoryboard> <storyboard> <doubleanimationusingkeyframes autoreverse="true" storyboard.targetproperty="(uielement.opacity)" > <easingdoublekeyframe keytime="0" value="0"/> <easingdoublekeyframe keytime="0:0:0.5" value="1"/> <easingdoublekeyframe keytime="0:0:3" value="1"/> <easingdoublekeyframe keytime="0:0:4" value="0"/> </doubleanimationusingkeyframes> </storyboard> </beginstoryboard> </datatrigger.enteractions> </datatrigger> </style.triggers> </style> </grid.resources> <grid.rowdefinitions> <rowdefinition/> <rowdefinition height="auto"/> </grid.rowdefinitions> <statusbar style="{staticresource statusstyle}" grid.row="1" itemssource="{binding items}" /> <checkbox content="checkbox" height="16" horizontalalignment="left" margin="41,30,0,0" ischecked="{binding pulse}" verticalalignment="top" /> </grid>
view model
public class mainviewmodel : viewmodelbase { private bool _pulse; public mainviewmodel() { items = new[] {"passed"}; } public ilist<string> items { get; private set; } public bool pulse { { return _pulse; } set { set(()=>pulse, ref _pulse, value); } } }
Comments
Post a Comment