The Layer dependency properties seem to be gone in 100.1? Was that intentional? Is there an alternative approach for binding to Layer properties? Thanks.
10.2.7
100.1
Solved! Go to Solution.
It is an intentional change for v100+. Were there specific binding scenarios that you're unable to do now? If yes, please share so we can try and accommodate in the future.
Meanwhile, you can try the following code. You should still be able to do binding to Layer properties.
xmlns:esri="http://schemas.esri.com/arcgis/runtime/2013">
<Grid>
<esri:MapView x:Name="MyMapView" />
<StackPanel VerticalAlignment="Top"
HorizontalAlignment="Right">
<ItemsControl ItemsSource="{Binding ElementName=MyMapView, Path=Map.AllLayers}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition MinWidth="50" />
</Grid.ColumnDefinitions>
<CheckBox IsChecked="{Binding IsVisible, Mode=TwoWay}"
Content="{Binding Name}" />
<Slider Value="{Binding Opacity, Mode=TwoWay}"
Minimum="0"
Maximum="1"
Grid.Column="1"/>
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</StackPanel>
</Grid>
public MainWindow()
{
InitializeComponent();
MyMapView.Map = new Map(Basemap.CreateTopographic());
MyMapView.Map.OperationalLayers.Add(new ArcGISMapImageLayer(new Uri("http://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer")));
MyMapView.Map.OperationalLayers.Add(new FeatureLayer(new Uri("https://sampleserver6.arcgisonline.com/arcgis/rest/services/Wildfire/FeatureServer/0")) { Name = "Wildfire" });
}
It is an intentional change for v100+. Were there specific binding scenarios that you're unable to do now? If yes, please share so we can try and accommodate in the future.
Meanwhile, you can try the following code. You should still be able to do binding to Layer properties.
xmlns:esri="http://schemas.esri.com/arcgis/runtime/2013">
<Grid>
<esri:MapView x:Name="MyMapView" />
<StackPanel VerticalAlignment="Top"
HorizontalAlignment="Right">
<ItemsControl ItemsSource="{Binding ElementName=MyMapView, Path=Map.AllLayers}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition MinWidth="50" />
</Grid.ColumnDefinitions>
<CheckBox IsChecked="{Binding IsVisible, Mode=TwoWay}"
Content="{Binding Name}" />
<Slider Value="{Binding Opacity, Mode=TwoWay}"
Minimum="0"
Maximum="1"
Grid.Column="1"/>
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</StackPanel>
</Grid>
public MainWindow()
{
InitializeComponent();
MyMapView.Map = new Map(Basemap.CreateTopographic());
MyMapView.Map.OperationalLayers.Add(new ArcGISMapImageLayer(new Uri("http://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer")));
MyMapView.Map.OperationalLayers.Add(new FeatureLayer(new Uri("https://sampleserver6.arcgisonline.com/arcgis/rest/services/Wildfire/FeatureServer/0")) { Name = "Wildfire" });
}
Jennifer,
I was able to use INotifyPropertyChanged instead of dependency properties. Thank you.
Jennifer,
I have a wrapper class around esri Layer that was binding to the dependency properties in Layer. I think I can do something similar by forwarding the properties and listening to change notifications. I'll investigate.
We really want to encourage users to think of the Map as the model that gets bound to the MapView, rather than binding individual layers. For example:
<esri:MapView Map="{Binding Map}" />
You can then reuse that object to bind else where, like for instance:
<Checkbox IsVisible="{Binding Map.OperationalLayers[MyLayerID],Visible, Mode=TwoWay}" />