wpf - How to fix treeItem.DisplayMemberPath when I apply the theme? -
i have treeview bind list of objects: when have no theme treeitem.displaymemberpath = "name" works well, when apply theme “bubblecreme.xaml” instead of “name” have “system.dataentity.dynamicproxies.food45484545…” in treeview here treeview style in theme if needed
<!-- treeview --> <style x:key="{x:type treeview}" targettype="{x:type treeview}"> <setter property="background" value="{staticresource primarybrush}" /> <setter property="foreground" value="{staticresource textbrush}" /> <setter property="horizontalcontentalignment" value="left" /> <setter property="verticalcontentalignment" value="top" /> <setter property="cursor" value="arrow" /> <setter property="borderthickness" value="1.5,1.5,.75,.75" /> <setter property="padding" value="1" /> <setter property="borderbrush"> <setter.value> <lineargradientbrush endpoint="0.5,1.5" startpoint="0.5,0"> <gradientstop color="{staticresource secondarycolor}" /> <gradientstop color="{staticresource primarycolor}" offset="1" /> </lineargradientbrush> </setter.value> </setter> <setter property="istabstop" value="false" /> <setter property="template"> <setter.value> <controltemplate targettype="{x:type treeview}"> <border x:name="root" borderbrush="{templatebinding borderbrush}" borderthickness="{templatebinding borderthickness}" background="{templatebinding background}" padding="{templatebinding padding}" cornerradius="4"> <grid> <grid x:name="innershadow" opacity="0.25" margin="-1"> <grid.columndefinitions> <columndefinition width="6" /> <columndefinition /> <columndefinition width="6" /> </grid.columndefinitions> <grid.rowdefinitions> <rowdefinition height="6" /> <rowdefinition /> <rowdefinition height="6" /> </grid.rowdefinitions> <border background="{staticresource secondarybrush}" cornerradius="2.5,0,0,0"> <border.opacitymask> <radialgradientbrush> <radialgradientbrush.relativetransform> <transformgroup> <scaletransform centerx="0.5" centery="0.5" scalex="2" scaley="2" /> <translatetransform x="0.5" y="0.5" /> </transformgroup> </radialgradientbrush.relativetransform> <gradientstop /> <gradientstop color="#ffffffff" offset="1" /> </radialgradientbrush> </border.opacitymask> </border> <border background="{staticresource secondarybrush}" grid.column="1"> <border.opacitymask> <lineargradientbrush endpoint="0.5,1" startpoint="0.5,0"> <gradientstop color="#ffffffff" offset="0" /> <gradientstop offset="1" /> </lineargradientbrush> </border.opacitymask> </border> <border background="{staticresource secondarybrush}" grid.column="2" cornerradius="0,2.5,0,0"> <border.opacitymask> <radialgradientbrush> <radialgradientbrush.relativetransform> <transformgroup> <scaletransform centerx="0.5" centery="0.5" scalex="2" scaley="2" /> <translatetransform x="-0.5" y="0.5" /> </transformgroup> </radialgradientbrush.relativetransform> <gradientstop /> <gradientstop color="#ffffffff" offset="1" /> </radialgradientbrush> </border.opacitymask> </border> <border background="{staticresource secondarybrush}" grid.row="1"> <border.opacitymask> <lineargradientbrush endpoint="1,.5" startpoint="0,.5"> <gradientstop color="#00000000" offset="1" /> <gradientstop color="#ffffffff" offset="0" /> </lineargradientbrush> </border.opacitymask> </border> <border background="{staticresource secondarybrush}" grid.column="1" grid.row="1" opacitymask="#00000000" /> <border background="{staticresource secondarybrush}" grid.column="2" grid.row="1"> <border.opacitymask> <lineargradientbrush endpoint="1,.5" startpoint="0,.5"> <gradientstop color="#ff000000" offset="1" /> <gradientstop color="#00ffffff" offset="0" /> </lineargradientbrush> </border.opacitymask> </border> <border background="{staticresource secondarybrush}" grid.row="2" cornerradius="0,0,0,2.5"> <border.opacitymask> <radialgradientbrush> <radialgradientbrush.relativetransform> <transformgroup> <scaletransform centerx="0.5" centery="0.5" scalex="2" scaley="2" /> <translatetransform x="0.5" y="-0.5" /> </transformgroup> </radialgradientbrush.relativetransform> <gradientstop /> <gradientstop color="#ffffffff" offset="1" /> </radialgradientbrush> </border.opacitymask> </border> <border background="{staticresource secondarybrush}" grid.column="1" grid.row="2"> <border.opacitymask> <lineargradientbrush endpoint="0.5,1" startpoint="0.5,0"> <gradientstop color="#00000000" offset="0" /> <gradientstop color="#ffffffff" offset="1" /> </lineargradientbrush> </border.opacitymask> </border> <border background="{staticresource secondarybrush}" grid.column="2" grid.row="2" cornerradius="0,0,2.5,0"> <border.opacitymask> <radialgradientbrush> <radialgradientbrush.relativetransform> <transformgroup> <scaletransform centerx="0.5" centery="0.5" scalex="2" scaley="2" /> <translatetransform x="-0.5" y="-0.5" /> </transformgroup> </radialgradientbrush.relativetransform> <gradientstop /> <gradientstop color="#ffffffff" offset="1" /> </radialgradientbrush> </border.opacitymask> </border> </grid> <scrollviewer x:name="scrollviewer" background="{x:null}" borderbrush="transparent" borderthickness="0" istabstop="false" horizontalscrollbarvisibility="auto" verticalscrollbarvisibility="auto"> <itemspresenter margin="5" x:name="treeitems" /> </scrollviewer> </grid> </border> </controltemplate> </setter.value> </setter> </style> <!-- treeviewitem --> <style x:key="{x:type treeviewitem}" targettype="{x:type treeviewitem}"> <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="borderbrush" value="{staticresource primarybrush}" /> <setter property="cursor" value="arrow" /> <setter property="istabstop" value="true" /> <setter property="template"> <setter.value> <controltemplate targettype="{x:type treeviewitem}"> <grid background="{x:null}" x:name="root"> <visualstatemanager.visualstategroups> <visualstategroup x:name="commonstates"> <visualstate x:name="normal" /> <visualstate x:name="disabled"> <storyboard> <objectanimationusingkeyframes duration="0" storyboard.targetname="header" storyboard.targetproperty="foreground"> <discreteobjectkeyframe keytime="0" value="#ff999999" /> </objectanimationusingkeyframes> <doubleanimationusingkeyframes duration="00:00:00.001" storyboard.targetname="root" storyboard.targetproperty="(uielement.opacity)"> <splinedoublekeyframe keytime="0" value="0.75" /> </doubleanimationusingkeyframes> </storyboard> </visualstate> </visualstategroup> </visualstatemanager.visualstategroups> <grid.rowdefinitions> <rowdefinition height="auto" /> <rowdefinition height="*" /> </grid.rowdefinitions> <grid.columndefinitions> <columndefinition width="15" /> <columndefinition width="auto" /> <columndefinition width="*" /> </grid.columndefinitions> <grid grid.column="1" opacity="0" x:name="grid"> <border x:name="background" cornerradius="12" borderbrush="{templatebinding borderbrush}" borderthickness=".5,0.5,1,1"> <border.background> <lineargradientbrush endpoint="0.5,1.75" startpoint="0.5,-.5"> <gradientstop color="{staticresource secondarycolor}" offset="0" /> <gradientstop color="{staticresource primarycolor}" offset=".01" /> <gradientstop color="{staticresource primarycolor}" offset=".3" /> <gradientstop color="{staticresource secondarycolor}" offset="1" /> </lineargradientbrush> </border.background> </border> <border x:name="halo" cornerradius="12" opacity=".65" background="{staticresource secondarybrush}" opacitymask="{staticresource halomask}" /> </grid> <togglebutton ischecked="{binding path=isexpanded, relativesource={relativesource templatedparent}}" clickmode="press" horizontalalignment="stretch" x:name="expander" verticalalignment="stretch" istabstop="false"> <togglebutton.template> <controltemplate targettype="togglebutton"> <grid x:name="root" background="transparent"> <visualstatemanager.visualstategroups> <visualstategroup x:name="commonstates"> <visualstate x:name="normal" /> <visualstate x:name="mouseover"> <storyboard> <doubleanimationusingkeyframes duration="00:00:00.001" storyboard.targetname="border" storyboard.targetproperty="(shape.strokethickness)"> <splinedoublekeyframe keytime="0" value="1.25" /> </doubleanimationusingkeyframes> </storyboard> </visualstate> <visualstate x:name="disabled"> <storyboard> <doubleanimation duration="0" storyboard.targetname="root" storyboard.targetproperty="opacity" to=".7" /> </storyboard> </visualstate> </visualstategroup> <visualstategroup x:name="checkstates"> <visualstate x:name="unchecked" /> <visualstate x:name="checked"> <storyboard> <doubleanimationusingkeyframes duration="00:00:00.001" storyboard.targetname="grid" storyboard.targetproperty="(uielement.rendertransform).(transformgroup.children)[0].(rotatetransform.angle)"> <splinedoublekeyframe keytime="0" value="45" /> </doubleanimationusingkeyframes> <doubleanimationusingkeyframes duration="00:00:00.001" storyboard.targetname="arrow" storyboard.targetproperty="(uielement.opacity)"> <splinedoublekeyframe keytime="0" value="1" /> </doubleanimationusingkeyframes> <doubleanimationusingkeyframes duration="00:00:00.001" storyboard.targetname="border" storyboard.targetproperty="(uielement.opacity)"> <splinedoublekeyframe keytime="0" value="0" /> </doubleanimationusingkeyframes> </storyboard> </visualstate> </visualstategroup> </visualstatemanager.visualstategroups> <grid horizontalalignment="right" margin="2 2 5 2"> <grid x:name="grid" horizontalalignment="center" verticalalignment="center" rendertransformorigin=".25,.8" height="10" width="5"> <grid.rendertransform> <transformgroup> <rotatetransform /> </transformgroup> </grid.rendertransform> <path x:name="arrow" stroke="{x:null}" strokelinejoin="miter" strokethickness=".75" data="m 0,0 l 0,10 l 5,5 z" fill="{staticresource textbrush}" opacity="0" /> <path x:name="border" stroke="{staticresource textbrush}" strokelinejoin="miter" strokethickness=".75" data="m 0,0 l 0,10 l 5,5 z" fill="{x:null}" /> </grid> </grid> </grid> </controltemplate> </togglebutton.template> </togglebutton> <button cursor="{templatebinding cursor}" horizontalalignment="{templatebinding horizontalcontentalignment}" x:name="header" verticalalignment="{templatebinding verticalcontentalignment}" background="{templatebinding background}" foreground="{templatebinding foreground}" istabstop="false" grid.column="1" clickmode="hover" content="{templatebinding header}" contenttemplate="{templatebinding headertemplate}" padding="8,3,8,3"> <button.template> <controltemplate targettype="button"> <grid background="{templatebinding background}"> <visualstatemanager.visualstategroups> <visualstategroup x:name="commonstates"> <visualstate x:name="normal" /> <visualstate x:name="pressed"> <storyboard> <doubleanimation duration="0" storyboard.targetname="hover" storyboard.targetproperty="opacity" to=".5" /> </storyboard> </visualstate> <visualstate x:name="disabled"> <storyboard> <doubleanimation duration="0" storyboard.targetname="content" storyboard.targetproperty="opacity" to=".55" /> </storyboard> </visualstate> </visualstategroup> </visualstatemanager.visualstategroups> <grid x:name="hover" opacity="0"> <border x:name="background" cornerradius="12" borderbrush="{templatebinding borderbrush}" borderthickness=".5,0.5,1,1"> <border.background> <lineargradientbrush endpoint="0.5,1.75" startpoint="0.5,-.5"> <gradientstop color="{staticresource secondarycolor}" offset="0" /> <gradientstop color="{staticresource primarycolor}" offset=".01" /> <gradientstop color="{staticresource primarycolor}" offset=".3" /> <gradientstop color="{staticresource secondarycolor}" offset="1" /> </lineargradientbrush> </border.background> </border> <border x:name="halo" cornerradius="12" opacity=".65" background="{staticresource secondarybrush}" opacitymask="{staticresource halomask}" /> </grid> <contentpresenter cursor="{templatebinding cursor}" horizontalalignment="left" margin="{templatebinding padding}" x:name="content" content="{templatebinding content}" contenttemplate="{templatebinding contenttemplate}" /> </grid> </controltemplate> </button.template> </button> <itemspresenter x:name="itemshost" visibility="visible" grid.column="1" grid.columnspan="2" grid.row="1" /> </grid> <controltemplate.triggers> <trigger property="isexpanded" value="false"> <setter property="visibility" value="collapsed" targetname="itemshost" /> </trigger> <trigger property="hasitems" value="false"> <setter property="visibility" value="hidden" targetname="expander" /> </trigger> <trigger property="ismouseover" value="true"> <trigger.enteractions> <beginstoryboard> <storyboard> <!--<doubleanimation duration="00:00:00.3" storyboard.targetname="mouseovergrid" storyboard.targetproperty="opacity" to="0.25" />--> </storyboard> </beginstoryboard> </trigger.enteractions> <trigger.exitactions> <beginstoryboard> <storyboard> <!--<doubleanimation duration="00:00:00.3" storyboard.targetname="mouseovergrid" storyboard.targetproperty="opacity" to="0" />--> </storyboard> </beginstoryboard> </trigger.exitactions> </trigger> <trigger property="isselected" value="true"> <trigger.enteractions> <beginstoryboard> <storyboard> <doubleanimationusingkeyframes duration="00:00:00.001" storyboard.targetname="grid" storyboard.targetproperty="(uielement.opacity)"> <splinedoublekeyframe keytime="0" value="1" /> </doubleanimationusingkeyframes> </storyboard> </beginstoryboard> </trigger.enteractions> <trigger.exitactions> <beginstoryboard> <storyboard> <doubleanimationusingkeyframes duration="00:00:00.001" storyboard.targetname="grid" storyboard.targetproperty="(uielement.opacity)"> <splinedoublekeyframe keytime="0" value="0" /> </doubleanimationusingkeyframes> </storyboard> </beginstoryboard> </trigger.exitactions> </trigger> <multitrigger> <multitrigger.conditions> <condition property="isselected" value="true" /> <condition property="isselectionactive" value="false" /> </multitrigger.conditions> <multitrigger.enteractions> <beginstoryboard> <storyboard> <!--<doubleanimation duration="0" storyboard.targetname="mouseovergrid" storyboard.targetproperty="opacity" to="0.5" />--> </storyboard> </beginstoryboard> </multitrigger.enteractions> <multitrigger.exitactions> <beginstoryboard> <storyboard> <!--<doubleanimation duration="00:00:00.3" storyboard.targetname="mouseovergrid" storyboard.targetproperty="opacity" to="0" />--> </storyboard> </beginstoryboard> </multitrigger.exitactions> </multitrigger> <trigger property="isenabled" value="false"> <setter property="foreground" value="{dynamicresource {x:static systemcolors.graytextbrushkey}}" /> </trigger> </controltemplate.triggers> </controltemplate> </setter.value> </setter> </style>
Comments
Post a Comment