<esri:Editor x:Key="MyBarriersEditor" LayerIDs="MyBarriersGraphicsLayer"
Map="{Binding ElementName=_Map}" />
<local:ClosestFacilityControl Map="{Binding ElementName=MyMap}" VerticalAlignment="Top" HorizontalAlignment="Center"/>
public Map Map
{
get { return GetValue(MapProperty) as Map; }
set { SetValue(MapProperty, value); }
}
public static readonly DependencyProperty MapProperty = DependencyProperty.Register("Map",
typeof(Map), typeof(ClosestFacilityControl), new PropertyMetadata(OnMapPropertyChanged));
private static void OnMapPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
ClosestFacilityControl control = d as ClosestFacilityControl;
Map newMap = e.NewValue as Map;
if(control!=null)
{
Editor editor = control.LayoutRoot.Resources["MyBarriersEditor"] as Editor;
if(editor!=null)
editor.Map = newMap;
editor = control.LayoutRoot.Resources["MyFacilitiesEditor"] as Editor;
if(editor!=null)
editor.Map = newMap;
editor = control.LayoutRoot.Resources["MyIncidentsEditor"] as Editor;
if(editor!=null)
editor.Map = newMap;
control.facilitiesGraphicsLayer = newMap.Layers["MyFacilitiesGraphicsLayer"] as GraphicsLayer;
control.IncidentsGraphicsLayer = newMap.Layers["MyIncidentsGraphicsLayer"] as GraphicsLayer;
control.barriersGraphicsLayer = newMap.Layers["MyBarriersGraphicsLayer"] as GraphicsLayer;
control.routeGraphicsLayer = newMap.Layers["MyRoutesGraphicsLayer"] as GraphicsLayer;
}
}
public Map Map
{
get { return GetValue(MapProperty) as Map; }
set { SetValue(MapProperty, value); }
}
public static readonly DependencyProperty MapProperty = DependencyProperty.Register("Map",
typeof(Map), typeof(ClosestFacilityControl), new PropertyMetadata(OnMapPropertyChanged));
.......
<esri:Map x:Name="_Map" Background="White" Extent="-117.23,34.03,-117.16,34.08" > .... </esri:Map>
Per your post, I should remove this piece of code and then use
public Map Map {
...
}
Is it right? If so, how can I define these graphicslayers? Thanks.
<local:ClosestFacilityControl x:Name="MyClosedFacility" Visibility="Collapsed" Height="240" Width="440" Canvas.Left="306" Canvas.Top="140" Map="{Binding ElementName=_Map}" />
<esri:Editor x:Key="MyBarriersEditor" LayerIDs="MyBarriersGraphicsLayer" Map="{Binding ElementName=MyMap}" />