c# - Cannot interact with items on the adorner layer -


enter image description here

the above image example of options menu in ms word 2010 when click on text box on document. trying implement similar using adorners in wpf , struggling implementation.

i have created 2 adorners called optionsbuttonadorner , advancedoptionsadorner. when click on item on canvas show optionsbuttonadorner little sliding animation , when click on optionsbuttonadorner show advancedoptionsadorner same sliding animation. got above tasking working , system renders both adorners correctly above picture.

but complicated part if try put inside advancedoptionsadorner, can disaplay button inside adorner not getting hittest on button (same other control if try put testbox cannot focus or interact it). if use snoop @ objects, can see button , textbox enabled , hittest set true. looking bit further getting mousedown events on canvas iteself rather adorner objects. thinking if approach wrong. below sample code advancedoptionsadorner

thanks , sorry such long post.

public designeritemadvancedoptionsadorner(designercontrol designeritem):base(designeritem)         {             _designeritem = designeritem;             datatemplate datatemplate = (datatemplate)findresource("designeritemadvancedoptionsadorner");             _contentpresenter = new contentpresenter() { contenttemplate = datatemplate, opacity = 0.75 };             loaded += designeritemadvancedoptionsadorner_loaded;             unloaded += designeritemadvancedoptionsadorner_unloaded;         } private void designeritemadvancedoptionsadorner_loaded(object sender, routedeventargs e)         {             double newdistance = math.round((_designeritem.controlactualwidth * activezoomlevel) + 50);             animatemargin(new thickness((_designeritem.controlactualwidth * activezoomlevel) + 45, 0, 0, 0), new thickness(newdistance, 0, 0, 0), 0.1);         } protected override visual getvisualchild(int index)         {             return _contentpresenter;         }         protected override int visualchildrencount         {             { return 1; }         } 

below datatemplate adorner

<datatemplate x:key="designeritemadvancedoptionsadorner">         <grid rendertransformorigin="0.5,0.5" margin="0,-10,0,0" height="320" width="160" horizontalalignment="left">             <path stroke="{dynamicresource applicationprimarycolour}" strokethickness="1" fill="white">                 <path.data>                     <combinedgeometry geometrycombinemode="union">                         <combinedgeometry.geometry1>                             <rectanglegeometry  rect="0,0,140,280">                                 <rectanglegeometry.transform>                                     <translatetransform x="10" />                                 </rectanglegeometry.transform>                             </rectanglegeometry>                         </combinedgeometry.geometry1>                         <combinedgeometry.geometry2>                             <pathgeometry>                                 <pathfigure startpoint="0,20">                                     <linesegment point="10,10" />                                     <linesegment point="10,30" />                                 </pathfigure>                             </pathgeometry>                         </combinedgeometry.geometry2>                     </combinedgeometry>                 </path.data>               </path>             <textblock text="options" horizontalalignment="center" verticalalignment="top" fontweight="bold" margin="0,5,0,0"/>             <button horizontalalignment="center" verticalalignment="center" height="40" width="100" content="test"/>         </grid>     </datatemplate> 

below render getting after implementing adorners.

enter image description here

edit -

managed working below render getting enter image description here

i wrong overriding getvisualchild , visualchildrencount methods. instead created visualcollection property in adorner class , added contentpresenter collection , overrides returned expected results visualcollection[i] visualchild , visualcollection.count visualchildrencount.

also did not have issue ui interactivity because passing in datacontext of item adorner , of commands going advancedoptions adorner prism composite commands , fired in relevant viewmodels

this impressive project-code - compliments! unfortunately, think adorner - while quite useful lot of 'adorning' purposes, not going serve here. need full interactivity control, adorner not intended provide. need, here, regular ux elements. adornments implemented sort of separate layer, rest of uielement tree. i've been down road myself, before realizing that. way, i'd love know more project, , how successful in implementing wpf. hit me if can of help. , best of wishes.


Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -