WPF XBAP treeview unable to select child item -
am using wpf xbap application treeview control. treeview has custom itemcontainerstyle , uses hierarchical data binding. when minimize browser running xbap , maximize again , click on item in treeview, item not getting selected ie. selecteditemchanged event handler not firing. below style i'm using treeviewitem:
<style x:key="treeviewitemfocusvisual"> <setter property="control.template"> <setter.value> <controltemplate> <rectangle margin="0,0,0,0" opacity="0"/> </controltemplate> </setter.value> </setter> </style> <style x:key="expandcollapsetogglestyle" targettype="{x:type togglebutton}"> <setter property="focusable" value="false"/> <setter property="width" value="10"/> <setter property="height" value="10"/> <setter property="template"> <setter.value> <controltemplate targettype="{x:type togglebutton}"> <image x:name="imgexpand" source="images/plus.png"/> <controltemplate.triggers> <trigger property="ischecked" value="true"> <setter property="source" targetname="imgexpand" value="images/minus.png"/> </trigger> </controltemplate.triggers> </controltemplate> </setter.value> </setter> </style> <style x:key="treeviewitemstyle" targettype="{x:type treeviewitem}"> <setter property="background" value="transparent"/> <setter property="horizontalcontentalignment" value="{binding horizontalcontentalignment, relativesource={relativesource ancestortype={x:type itemscontrol}}}"/> <setter property="verticalcontentalignment" value="{binding verticalcontentalignment, relativesource={relativesource ancestortype={x:type itemscontrol}}}"/> <setter property="padding" value="1,0,0,0"/> <setter property="foreground" value="{dynamicresource {x:static systemcolors.controltextbrushkey}}"/> <setter property="focusvisualstyle" value="{staticresource treeviewitemfocusvisual}"/> <setter property="isexpanded" value="{binding path=isitemexpanded}" /> <!--<setter property="isselected" value="{binding path=isentityselected}" />--> <setter property="template"> <setter.value> <controltemplate targettype="{x:type treeviewitem}"> <grid x:name="grd"> <grid.columndefinitions> <columndefinition width="auto"/> <columndefinition width="auto"/> <columndefinition width="*"/> </grid.columndefinitions> <grid.rowdefinitions> <rowdefinition height="auto"/> <rowdefinition/> </grid.rowdefinitions> <rectangle x:name="horln" height="1" margin="10,0,0,0" renderoptions.edgemode="aliased" stroke="white" snapstodevicepixels="true" strokedasharray="1 2" strokethickness="1"/> <rectangle x:name="verln" width="1" grid.rowspan="2" renderoptions.edgemode="aliased" stroke="white" snapstodevicepixels="true" strokedasharray="1 2" strokethickness="1"/> <togglebutton x:name="expander" style="{staticresource expandcollapsetogglestyle}" clickmode="press" ischecked="{binding isexpanded, relativesource={relativesource templatedparent}}"/> <stackpanel orientation="horizontal" grid.column="1" > <!--<image width="16" height="16" margin="0" source="{binding path=imagesource}" x:name="imgflag"/>--> <border x:name="bd" snapstodevicepixels="true" background="{templatebinding background}" borderbrush="{templatebinding borderbrush}" borderthickness="{templatebinding borderthickness}" margin="0" padding="0"> <contentpresenter x:name="part_header" horizontalalignment="{templatebinding horizontalcontentalignment}" snapstodevicepixels="{templatebinding snapstodevicepixels}" contentsource="header"/> </border> </stackpanel> <itemspresenter x:name="itemshost" grid.column="1" grid.row="1"/> </grid> <controltemplate.triggers> <datatrigger binding="{binding relativesource={relativesource self}, converter={x:static converters:treeviewlineconverter.instance}}" value="true"> <setter targetname="verln" property="height" value="1"/> <setter targetname="verln" property="verticalalignment" value="top"/> </datatrigger> <trigger property="isexpanded" value="false"> <setter property="visibility" targetname="itemshost" value="collapsed"/> </trigger> <trigger property="hasitems" value="false"> <setter property="visibility" targetname="expander" value="hidden"/> </trigger> <trigger property="isselected" value="true"> <setter property="background" targetname="bd" value="#71a3ff"/> <setter property="control.foreground" targetname="bd" value="{dynamicresource {x:static systemcolors.highlighttextbrushkey}}"/> </trigger> <trigger property="isfocused" value="true"> <setter property="background" targetname="bd" value="{dynamicresource {x:static systemcolors.controlbrushkey}}"/> </trigger> <multitrigger> <multitrigger.conditions> <condition property="isselected" value="true"/> <condition property="isselectionactive" value="true"/> </multitrigger.conditions> <setter property="background" targetname="bd" value="#71a3ff"/> <setter property="control.foreground" targetname="bd" value="{dynamicresource {x:static systemcolors.controltextbrushkey}}"/> </multitrigger> <multitrigger> <multitrigger.conditions> <condition property="isselected" value="true"/> <condition property="isselectionactive" value="false"/> </multitrigger.conditions> <setter property="background" targetname="bd" value="#71a3ff"/> <setter property="control.foreground" targetname="bd" value="{dynamicresource {x:static systemcolors.controltextbrushkey}}"/> </multitrigger> <trigger property="isenabled" value="false"> <setter property="foreground" value="{dynamicresource {x:static systemcolors.graytextbrushkey}}"/> </trigger> </controltemplate.triggers> </controltemplate> </setter.value> </setter> <style.triggers> <trigger property="virtualizingstackpanel.isvirtualizing" value="true"> <setter property="itemspanel"> <setter.value> <itemspaneltemplate> <virtualizingstackpanel/> </itemspaneltemplate> </setter.value> </setter> </trigger> </style.triggers> </style>
thanks in advance.
disclaimer: educated guess
in window
class, there deactivated
, activated
events called whenever focus removed or returned window
object. if have similar events in xbap top level window
object, may able utilise them. [i'm sorry, msdn down can't verify if correct.]
if can attach activated
event, possibly refresh ui restore full functionality each time application focused again.
Comments
Post a Comment