Ich muss Zeile auf MapControl zeichnen. Ich habe XAML-Ansicht meine MapControl:Erweiterung für MapControl C# UWP
<Maps:MapControl x:Name="mapMain"
MapServiceToken="{StaticResource MapServiceTokenString}"
RenderTransformOrigin="0.5,0.5"
Margin="0,0,0,0"
extentions:PolyLineMapControl.ItemsCollection="{Binding mapViewModel.PointsOfNodes}">
<Maps:MapItemsControl x:Name="ItemsChanged"
ItemsSource="{x:Bind mapViewModel.PointsOfNodes, Mode=OneWay}">
<Maps:MapItemsControl.ItemTemplate>
<DataTemplate x:DataType="data:PointOfNode">
<StackPanel>
<Border Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<TextBlock Text="{x:Bind DisplayName, Mode=OneWay}"/>
</Border>
<Image Source="{x:Bind ImageSourcePath, Mode=OneWay}"
Maps:MapControl.Location="{x:Bind Location, Mode=OneWay}"
Maps:MapControl.NormalizedAnchorPoint="{x:Bind NormalizedAnchorPoint, Mode=OneWay}">
<Image.Transitions>
<TransitionCollection>
<EntranceThemeTransition/>
</TransitionCollection>
</Image.Transitions>
</Image>
</StackPanel>
</DataTemplate>
</Maps:MapItemsControl.ItemTemplate>
</Maps:MapItemsControl>
</Maps:MapControl>
ich Punkte von mapViewModel successfuly, aber extention doesn `t Arbeit.
public class PolyLineMapControl
{
public static readonly DependencyProperty ItemsCollectionProperty = DependencyProperty.RegisterAttached("ItemsCollection", typeof(List<PointOfNode>), typeof(PolyLineMapControl), new PropertyMetadata(default(List<PointOfNode>), OnItemsChanged));
public static List<PointOfNode> GetItemsCollection(DependencyObject obj)
{
return (List<PointOfNode>)obj.GetValue(ItemsCollectionProperty);
}
public static void SetItemsCollection(DependencyObject obj, List<PointOfNode> value)
{
obj.SetValue(ItemsCollectionProperty, value);
}
private static void OnItemsChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
//draw line
}
}
Die Eigenschaft wird erfolgreich initialisiert. Ich habe dies festgestellt, wenn ich brakpoint in Setter, Getter, Wechsler-Methoden und Eigenschaften gesetzt habe.
Ok, ich änderte die Liste zu ObservableCollection Start App ein ging zu Setter. aber nicht mehr –
Wofür wird "PolyLineMapControl" verwendet? –
Ich habe einige Punkte ObservableCollection, die Karte wie ein Bild aufstellen. MapItemsControl hat eine Bindung an diese Sammlung. Wenn sich die Sammlung geändert hat, muss ich Punkte sammeln. –