Set Bing Maps Center in Windows 8 Store App using XAML C# -


i trying set center location on bing maps control in windows 8 store app using xaml/c#. came across articles explaining cannot use binding center property in xaml trying set in c#. using default windows 8 store app grid template in studio.

 <flipview         x:name="flipview"         automationproperties.automationid="itemsflipview"         automationproperties.name="item details"         tabindex="1"         grid.rowspan="2"         itemssource="{binding source={staticresource itemsviewsource}}">          <flipview.itemcontainerstyle>             <style targettype="flipviewitem">                 <setter property="margin" value="0,137,0,0"/>             </style>         </flipview.itemcontainerstyle>          <flipview.itemtemplate>             <datatemplate>                  <!--                     usercontrol chosen templated item because supports visual state management                     loaded/unloaded events explicitly subscribe view state updates page                 -->                 <usercontrol loaded="startlayoutupdates" unloaded="stoplayoutupdates">                     <scrollviewer x:name="scrollviewer" style="{staticresource horizontalscrollviewerstyle}" grid.row="1">                          <!-- content allowed flow across many columns needed -->                         <common:richtextcolumns x:name="richtextcolumns" margin="117,0,117,47">                             <richtextblock x:name="richtextblock" width="560" style="{staticresource itemrichtextstyle}" istextselectionenabled="false">                                 <paragraph>                                     <run fontsize="26.667" fontweight="medium" text="{binding title}"/>                                     <linebreak/>                                     <run fontsize="16.667" fontweight="light" text="{binding eventstartdate,converter={staticresource stringconverter},converterparameter='{}{0:d}'}"/>                                 </paragraph>                                 <paragraph linestackingstrategy="maxheight">                                     <inlineuicontainer>                                         <!--<image x:name="image" maxheight="480" margin="0,20,0,10" stretch="uniform" source="{binding image}" automationproperties.name="{binding title}"/>-->                                         <bm:map credentials="{staticresource bingmapsapikey}" height="500" width="560" margin="0,20,0,10"                                                  zoomlevel="10" x:name="mymap">                                             <bm:map.children>                                                 <bm:pushpin background="red">                                                     <bm:maplayer.position>                                                         <bm:location latitude="{binding place.latitude}" longitude="{binding place.longitude}" />                                                     </bm:maplayer.position>                                                 </bm:pushpin>                                             </bm:map.children>                                         </bm:map>                                     </inlineuicontainer>                                 </paragraph>                                 <paragraph>                                     <run fontsize="18.667" fontweight="normal" text="{binding place.placename}"/>                                     <linebreak/>                                     <run fontsize="16.667" fontweight="light" text="{binding place.addressline1txt}"/>                                     <linebreak/>                                     <run fontsize="16.667" fontweight="light" text="{binding place.cityname}"/>                                     <run fontsize="16.667" fontweight="light" text="{binding place.stateprovincecode}"/>                                     <run fontsize="16.667" fontweight="light" text="{binding place.postalcode}"/>                                     <linebreak/>                                     <linebreak/>                                     <inlineuicontainer>                                         <hyperlinkbutton margin="-15,0,0,0"  navigateuri="{binding homepageurl}" content="{binding homepageurl}" />                                     </inlineuicontainer>                                     <linebreak/>                                     <run fontweight="semilight" text="{binding content}"/>                                 </paragraph>                             </richtextblock> 

i unable locate bing maps control (bm:map) inside flipview control can set center. have tried winrt xaml toolkit codeplex using visualtree helpers , didnt work.

any appreciated. thx.

if going change value 1 time, register loaded of map :

   private void map_onloaded(object sender, routedeventargs e)     {         map map = sender map;         item item=map.datacontext item;         map.center = item.center;     } 

if need change several time, use attached property, should work:

public static readonly dependencyproperty mapcenterproperty =         dependencyproperty.registerattached("mapcenter", typeof (location), typeof (myattached),          new propertymetadata(default(location),mapcenterchanged));      private static void mapcenterchanged(dependencyobject d, dependencypropertychangedeventargs e)     {         map map = d map;         location location = e.newvalue location;         if (map != null &&location!=null)         {             map.center = location;         }     }        public static void setmapcenter(uielement element, location value)     {         element.setvalue(mapcenterproperty, value);     }      public static location getmapcenter(uielement element)     {         return (location) element.getvalue(mapcenterproperty);     } 

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -