Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I finally make it work by using dependency property. I added a new class:</p> <pre><code>public static class MapPushPinDependency { public static readonly DependencyProperty ItemsSourceProperty = DependencyProperty.RegisterAttached( "ItemsSource", typeof(IEnumerable), typeof(MapPushPinDependency), new PropertyMetadata(OnPushPinPropertyChanged)); private static void OnPushPinPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { UIElement uie = (UIElement)d; var pushpin = MapExtensions.GetChildren((Map)uie).OfType&lt;MapItemsControl&gt;().FirstOrDefault(); pushpin.ItemsSource = (IEnumerable)e.NewValue; } #region Getters and Setters public static IEnumerable GetItemsSource(DependencyObject obj) { return (IEnumerable)obj.GetValue(ItemsSourceProperty); } public static void SetItemsSource(DependencyObject obj, IEnumerable value) { obj.SetValue(ItemsSourceProperty, value); } #endregion } </code></pre> <p>And in the .xaml file I have added</p> <pre><code>xmlns:dp="clr-namespace:Treks.App.Util.DependencyProperties" </code></pre> <p>and now the .xaml file looks like this:</p> <pre><code>&lt;maps:Map x:Name="NearbyMap" Center="{Binding MapCenter, Mode=TwoWay}" ZoomLevel="{Binding ZoomLevel, Mode=TwoWay}" dp:MapPushPinDependency.ItemsSource="{Binding Path=Treks}" &gt; &lt;maptk:MapExtensions.Children&gt; &lt;maptk:MapItemsControl Name="StoresMapItemsControl"&gt; &lt;maptk:MapItemsControl.ItemTemplate&gt; &lt;DataTemplate&gt; &lt;maptk:Pushpin x:Name="PushPins" GeoCoordinate="{Binding Location}" Visibility="Visible" Content="test"/&gt; &lt;/DataTemplate&gt; &lt;/maptk:MapItemsControl.ItemTemplate&gt; &lt;/maptk:MapItemsControl&gt; &lt;maptk:UserLocationMarker x:Name="UserLocationMarker" Visibility="Visible" GeoCoordinate="{Binding MyLocation}"/&gt; &lt;/maptk:MapExtensions.Children&gt; &lt;/maps:Map&gt; </code></pre> <p>Now all the pushpins are correctly rendered.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload