<UserControl x:Class="RadioButtonDataBinding.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:esri="http://schemas.esri.com/arcgis/client/2009"> <Grid x:Name="LayoutRoot" Background="White"> <Grid.RowDefinitions> <RowDefinition Height="*"/> <RowDefinition Height="50"/> <RowDefinition Height="50"/> </Grid.RowDefinitions> <esri:Map x:Name="MyMap" Extent="-120,20,-90,60" Grid.Row="0"> <esri:ArcGISTiledMapServiceLayer ID="StreetMapLayer" Url="http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_ShadedRelief_World_2D/MapServer" Visible="{Binding IsChecked, ElementName=rbtn01}"/> <esri:ArcGISDynamicMapServiceLayer ID="DynamicLayer" Opacity="0.6" Url="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StateCityHighway_USA/MapServer" Visible="{Binding IsChecked, ElementName=rbtn02}" /> </esri:Map> <StackPanel Orientation="Horizontal" Grid.Row="1"> <RadioButton x:Name="rbtn01" IsThreeState="False" IsChecked="True" Content="World 2D Map" Margin="5" GroupName="MapLayers" Checked="rbtn01_Checked" Unchecked="rbtn01_Unchecked"/> <RadioButton x:Name="rbtn02" IsThreeState="False" IsChecked="False" Content="USA Map" Margin="5" GroupName="MapLayers" Checked="rbtn02_Checked" Unchecked="rbtn02_Unchecked"/> </StackPanel> <StackPanel Orientation="Horizontal" Grid.Row="2"> <Button Content="Button 01" Width="100" Height="25" IsEnabled="{Binding IsChecked, ElementName=rbtn01}" Margin="5"/> <Button Content="Button 02" Width="100" Height="25" IsEnabled="{Binding IsChecked, ElementName=rbtn02}" Margin="5"/> </StackPanel> </Grid> </UserControl>
...because you are binding from a non-UIElement.
That being said, I can't explain why it's not working other way....
<esri:Map x:Name="MyMap" Extent="-120,20,-90,60" Grid.Row="0"> <esri:ArcGISTiledMapServiceLayerID="StreetMapLayer" Url="http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_ShadedRelief_World_2D/MapServer" Visible="True"/> <esri:ArcGISDynamicMapServiceLayer ID="DynamicLayer" Opacity="0.6" Url="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StateCityHighway_USA/MapServer" Visible="False" /> </esri:Map> <StackPanel Orientation="Horizontal" Grid.Row="1"> <RadioButton x:Name="rbtn01" IsThreeState="False" IsChecked="{Binding Layers[0].Visible, ElementName=MyMap, Mode=TwoWay}" Content="World 2D Map" Margin="5" GroupName="MapLayers" /> <RadioButton x:Name="rbtn02" IsThreeState="False" IsChecked="{Binding Layers[1].Visible, ElementName=MyMap, Mode=TwoWay}" Content="USA Map" Margin="5" GroupName="MapLayers"/> </StackPanel>
Les membres connectés peuvent publier, suivre les mises à jour, et plus encore. Nouveau ici ? Inscrivez-vous gratuitement.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.