<esri:GraphicCollection x:Key="MyGraphics" />
<esri:GraphicsLayer ID="MyGraphicsLayer" Graphics="{Binding Source={StaticResource MyGraphics}}">
public class MyViewModelObject : INotifyPropertyChanged { public MyViewModelObject() { Graphics = new GraphicCollection(); } private GraphicCollection graphics; public GraphicCollection Graphics { get { return graphics; } set { if (graphics != value) { graphics = value; OnPropertyChanged("Graphics"); } } } public event PropertyChangedEventHandler PropertyChanged; public void OnPropertyChanged(string property) { if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs(property)); }
MyViewModelObject obj = new MyViewModelObject(); this.DataContext = obj;
<esri:GraphicsLayer ID="MyGraphicsLayer" Graphics="{Binding Graphics}">
<Grid.Resources> <local:MyViewModelObject x:Key="obj"/> </Grid.Resources> <!-- more code here --> <esri:GraphicsLayer ID="MyGraphicsLayer" Graphics="{Binding Source={StaticResource obj}, Path=Graphics, Mode=TwoWay}" >
MyViewModelObject obj = new MyViewModelObject(); GraphicsLayer layer = this.MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer; System.Windows.Data.Binding binding = new System.Windows.Data.Binding("Graphics"); binding.Source = obj; binding.Mode = System.Windows.Data.BindingMode.TwoWay; System.Windows.Data.BindingOperations.SetBinding(layer, GraphicsLayer.GraphicsProperty, binding);
obj.Graphics.Add(new Graphic() { Geometry = new MapPoint(17, 15) });
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.