c# - WPF Expander ScrollViewer throwing exception when window is closed -
i'm showing expander in modal window. if don't toggle expander window close fine. once i've toggled , close window throws exception on invocation of
system.windows.media.animation.doubleanimationbase.getcurrentvalue(object defaultoriginvalue, object defaultdestinationvalue, animationclock animationclock)
i have same control on window works fine.
i define control follows
<expander template="{dynamicresource moreinformationexpander}"> <stackpanel> <textblock text="{binding moreinformationtext} /> </stackpanel> </expander>
the template expander:
<controltemplate x:key="moreinformationexpander" targettype="{x:type expander}"> <dockpanel horizontalalignment="stretch"> <togglebutton x:name="expanderbutton" dockpanel.dock="bottom" template="{staticresource moreinformationexpanderbutton}" ischecked="{binding path=isexpanded, relativesource={relativesource templatedparent}}" overridesdefaultstyle="true" horizontalalignment="left"> </togglebutton> <scrollviewer x:name="expandercontentscrollview" dockpanel.dock="top" horizontalscrollbarvisibility="hidden" verticalscrollbarvisibility="hidden" horizontalalignment="stretch" horizontalcontentalignment="stretch" verticalcontentalignment="bottom" background="{dynamicresource windowbordergraybrush}" padding="8,4,0,0"> <scrollviewer.tag> <system:double>0.0</system:double> </scrollviewer.tag> <scrollviewer.height> <multibinding converter="{staticresource multiplyconverter}"> <binding path="actualheight" elementname="expandercontent"/> <binding path="tag" relativesource="{relativesource self}" /> </multibinding> </scrollviewer.height> <contentpresenter x:name="expandercontent" contentsource="content"/> </scrollviewer> </dockpanel> <controltemplate.triggers> <trigger property="isexpanded" value="true"> <trigger.enteractions> <beginstoryboard> <storyboard> <doubleanimation storyboard.targetname="expandercontentscrollview" storyboard.targetproperty="tag" to="1" duration="0:0:0.4"/> </storyboard> </beginstoryboard> </trigger.enteractions> <trigger.exitactions> <beginstoryboard> <storyboard> <doubleanimation storyboard.targetname="expandercontentscrollview" storyboard.targetproperty="tag" to="0" duration="0:0:0.4"/> </storyboard> </beginstoryboard> </trigger.exitactions> </trigger> </controltemplate.triggers> </controltemplate>
the template toggle button:
<controltemplate x:key="moreinformationexpanderbutton" targettype="{x:type togglebutton}"> <grid > <textblock name="tb" foreground="{dynamicresource bluesolidbrush}" fontsize="14" textdecorations="underline"/> </grid> <controltemplate.triggers> <trigger property="ischecked" value="true"> <setter property="text" value="less information" targetname="tb" /> </trigger> <trigger property="ischecked" value="false"> <setter property="text" value="more information" targetname="tb" /> </trigger> <trigger property="ismouseover" value="true"> <setter property="cursor" value="hand" /> </trigger> </controltemplate.triggers> </controltemplate>
the multiply converter:
public object convert(object[] values, type targettype, object parameter, cultureinfo culture) { double result = 1.0; (int = 0; < values.length; i++) { if (values[i] double) { result *= (double)values[i]; } } return result; }
exception , stack trace
an unhandled exception occurred, , application terminating. error details: cannot animate 'tag' property on 'system.windows.controls.scrollviewer' using 'system.windows.media.animation.doubleanimation'. details see inner exception.
=========================================================================
at system.windows.media.animation.doubleanimationbase.getcurrentvalue(object defaultoriginvalue, object defaultdestinationvalue, animationclock animationclock) @ system.windows.media.animation.animationlayer.getcurrentvalue(object defaultdestinationvalue) @ system.windows.media.animation.animationstorage.getcurrentpropertyvalue(animationstorage storage, dependencyobject d, dependencyproperty dp, propertymetadata metadata, object basevalue) @ system.windows.media.animation.animationstorage.oncurrenttimeinvalidated(object sender, eventargs args)
Comments
Post a Comment