Layer Dependency Properties gone in 100.1?

1001
4
Jump to solution
09-08-2017 06:07 AM
ChrisSmith10
New Contributor II

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

Layer Class 

100.1

Layer Class 

0 Kudos
1 Solution

Accepted Solutions
JenniferNery
Esri Regular Contributor

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" });            
        }

View solution in original post

0 Kudos
4 Replies
JenniferNery
Esri Regular Contributor

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" });            
        }
0 Kudos
ChrisSmith10
New Contributor II

Jennifer,

   I was able to use INotifyPropertyChanged instead of dependency properties. Thank you.

0 Kudos
ChrisSmith10
New Contributor II

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.

0 Kudos
dotMorten_esri
Esri Notable Contributor

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}" />