c# - Set mapcontrol's children topmost -
i'm adding stackpanel mapcontrol. below
but of points added before on top of stackpanel. how set stackpanel topmost?
xaml:
<grid x:name="gridmain"> <maps:mapcontrol x:name="mapcontrol" zoominteractionmode="gestureandcontrol" tiltinteractionmode="gestureandcontrol" rotateinteractionmode="gestureandcontrol"> <!--zoomlevel="{x:bind viewmodel.zoomlevel, mode=oneway}" center="{x:bind viewmodel.center, mode=oneway}"--> <maps:mapitemscontrol x:name="mapitems"> <maps:mapitemscontrol.itemtemplate> <datatemplate> <grid tapped="magpoint_tapped" maps:mapcontrol.normalizedanchorpoint="{binding normalizedanchorpoint}" maps:mapcontrol.location="{binding location}"> <ellipse canvas.zindex="0" width="{binding mag5}" height="{binding mag5}" fill="{binding magcolor}"/> <!--<textblock text="{binding mag}"/>--> </grid> </datatemplate> </maps:mapitemscontrol.itemtemplate> </maps:mapitemscontrol> </maps:mapcontrol> </grid> and add panel code.
stackpanel sp = new stackpanel(); sp.background = new solidcolorbrush(colors.white); sp.cornerradius = new cornerradius(15); sp.borderbrush = new solidcolorbrush(colors.lightgray); sp.borderthickness = new thickness(1); sp.width = 260; sp.minheight = 180; sp.padding = new thickness(10); canvas.setzindex(sp, 99999); mapcontrol.children.add(sp); windows.ui.xaml.controls.maps.mapcontrol.setlocation(sp, new geopoint(new basicgeoposition { longitude = (double)fi.geometry.coordinates[0], latitude = (double)fi.geometry.coordinates[1] })); windows.ui.xaml.controls.maps.mapcontrol.setnormalizedanchorpoint(sp, new point(0.5, 1));
your way of setting zindex wouldn't work because stackpanel , items inside mapitemscontrol in different hosts.
with of live visual tree, can find out how laid out.
in screenshot above, stackpanel's host (i.e. first canvas) placed behind mapoverlaypresenters host (i.e. second canvas mapitemscontrol inserted). in order have stackpanel sit above them, need manually set zindex of first canvas 1.
once understand this, solution becomes simple -
loaded += (s, e) => { // getchildbyname comes // https://github.com/justinxinliu/continuity/blob/0cc3d7556c747a060d40bae089b80eb845da84fa/continuity/extensions/utilextensions.cs#l44 var layergrid = mapcontrol.getchildbyname<grid>("layergrid"); var canvas1 = layergrid.children.first(); canvas.setzindex(canvas1, 1); }; hope helps!


Comments
Post a Comment