Hello,
I want to show a point on the map. I want to show the location of this point by data binding path.
I have a xaml code like below. While binding data to ImagerLayer, midpoint shows null when binding to MapCircle.
Center="{Binding DevicePoint}"
Fill="Blue"/>
ViewModel
public Point DevicePoint
{
get => _devicePoint;
set => SetProperty(ref _devicePoint, value);
}
Error : Cannot find governing FrameworkElement or FrameworkContentElement for targer element.
|
<Window.DataContext>
<mapwpf:ViewModel />
</Window.DataContext>
…
<maps:ImageryLayer.SubShapeFileLayers>
<maps:SubShapeFileLayer x:Name="subLayer"
MapElements="{Binding MapElements}">
</maps:SubShapeFileLayer>
</maps:ImageryLayer.SubShapeFileLayers> |
|
In ViewModel.cs
public ObservableCollection<MapElement> MapElements { get; set; }
…
public ViewModel()
{
this.DevicePoint = new Point(43.76140927456403, -79.35451013248883);
this.MapElements = new ObservableCollection<MapElement>();
var mapCircle = new MapCircle
{
Fill = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#3eFF0000")),
Stroke = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#73FF0000")),
StrokeThickness = 3,
Radius = 110
};
Binding binding = new Binding();
binding.Source = this;
binding.Path = new PropertyPath(nameof(this.DevicePoint));
BindingOperations.SetBinding(mapCircle, MapCircle.CenterProperty, binding);
this.MapElements.Add(mapCircle);
} |
Thank you for answer. It's work.