i have listbox itemcontainerstyle
below. provides nice fade-in, , slide out when items added or removed itemssource respectively; works fine.
the problem occurs when put list box tabcontrol sl toolkit. when load items listbox, flip tab, flip back, if remove item, see animation occur, right it's finish, following nullreferenceexception exception:
at system.windows.controls.itemcontainergenerator.layoutstatesmanager._layoutstatesgroups_currentstatechanged(object sender, visualstatechangedeventargs e) @ ms.internal.coreinvokehandler.invokeeventhandler(int32 typeindex, delegate handlerdelegate, object sender, object args) @ ms.internal.jolthelper.fireevent(intptr unmanagedobj, intptr unmanagedobjargs, int32 argstypeindex, int32 actualargstypeindex, string eventname)
to make matters worse, happens when use custom itemspanel, ie horizontal stackpanel instead of default virtualizingpanel.
here's complete template:
<style x:key="listboxstyleanimatedaddandremove" targettype="listboxitem"> <setter property="padding" value="3"/> <setter property="horizontalcontentalignment" value="left"/> <setter property="verticalcontentalignment" value="top"/> <setter property="background" value="transparent"/> <setter property="borderthickness" value="1"/> <setter property="tabnavigation" value="local"/> <setter property="template"> <setter.value> <controltemplate targettype="listboxitem"> <grid background="{templatebinding background}" x:name="rootgridelement"> <visualstatemanager.visualstategroups> <visualstategroup x:name="layoutstates"> <visualstate x:name="afterloaded"> <storyboard> <doubleanimation duration="00:00:1" from="0" to="1" storyboard.targetname="rootgridelement" storyboard.targetproperty="opacity" /> </storyboard> </visualstate> <visualstate x:name="beforeunloaded" /> <visualstategroup.transitions> <visualtransition from="afterloaded" to="beforeunload" generatedduration="0:0:0.5"> <storyboard> <doubleanimation duration="00:00:0.25" by="235" storyboard.targetname="contentprojection" storyboard.targetproperty="globaloffsety" /> </storyboard> </visualtransition> </visualstategroup.transitions> </visualstategroup> <visualstategroup x:name="commonstates"> <visualstate x:name="normal" /> <visualstate x:name="mouseover"> <storyboard> <doubleanimation duration="0" to=".35" storyboard.targetproperty="opacity" storyboard.targetname="fillcolor"/> </storyboard> </visualstate> <visualstate x:name="disabled"> <storyboard> <doubleanimation duration="0" to=".55" storyboard.targetproperty="opacity" storyboard.targetname="contentpresenter"/> </storyboard> </visualstate> </visualstategroup> <visualstategroup x:name="selectionstates"> <visualstate x:name="unselected"/> <visualstate x:name="selected"> <storyboard> <doubleanimation duration="0" to=".75" storyboard.targetproperty="opacity" storyboard.targetname="fillcolor2"/> </storyboard> </visualstate> </visualstategroup> <visualstategroup x:name="focusstates"> <visualstate x:name="focused"> <storyboard> <objectanimationusingkeyframes duration="0" storyboard.targetproperty="visibility" storyboard.targetname="focusvisualelement"> <discreteobjectkeyframe keytime="0"> <discreteobjectkeyframe.value> <visibility>visible</visibility> </discreteobjectkeyframe.value> </discreteobjectkeyframe> </objectanimationusingkeyframes> </storyboard> </visualstate> <visualstate x:name="unfocused"/> </visualstategroup> </visualstatemanager.visualstategroups> <rectangle x:name="fillcolor" fill="#ffbadde9" ishittestvisible="false" opacity="0" radiusy="1" radiusx="1"/> <rectangle x:name="fillcolor2" fill="#ffbadde9" ishittestvisible="false" opacity="0" radiusy="1" radiusx="1"/> <contentpresenter x:name="contentpresenter" content="{templatebinding content}" contenttemplate="{templatebinding contenttemplate}" horizontalalignment="{templatebinding horizontalcontentalignment}" margin="{templatebinding padding}"> <contentpresenter.projection> <planeprojection x:name="contentprojection"> </planeprojection> </contentpresenter.projection> </contentpresenter> <rectangle x:name="focusvisualelement" radiusy="1" radiusx="1" stroke="#ff6dbdd1" strokethickness="1" visibility="collapsed"/> </grid> </controltemplate> </setter.value> </setter> </style>
Comments
Post a Comment