I am trying to understand the following sample code. It works find but I have difficulty to understand how the Binding works:
In the first use of Binding, we set the path and then the rest we omitted the path. is it because the other objects are the children of the Listbox?
Can somebody write a XAML code for me to put only one checkbox (no parent and no child, only one checkbox) and link the checked value to the layer visibility. I want to see how you will use the Binding to set the path as well as visibility.
Sorry, I am newbie in XAML and the Binding thing is seriously confusing.
<Border Background="#77919191" BorderThickness="1" CornerRadius="5"
HorizontalAlignment="Right" VerticalAlignment="Top"
Margin="20" Padding="5" BorderBrush="Black" >
<ListBox x:Name="MyList" ItemsSource="{Binding ElementName=MyMap, Path=Layers}">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<!--Layer visibility checkbox-->
<CheckBox IsChecked="{Binding Visible, Mode=TwoWay}" />
<!--Opacity slider-->
<Slider Margin="-5,0,0,0" Minimum="0" Maximum="1" Width="30"
Value="{Binding Opacity, Mode=TwoWay}" Height="18" />
<!--Layer name-->
<TextBlock Text="{Binding ID, Mode=OneWay}" Margin="5,0,0,0" >
<!-- Tooltip on hover-->
<ToolTipService.ToolTip>
<StackPanel MaxWidth="400">
<TextBlock FontWeight="Bold" Text="{Binding CopyrightText}" TextWrapping="Wrap" />
<TextBlock Text="{Binding Description}" TextWrapping="Wrap" />
</StackPanel>
</ToolTipService.ToolTip>
</TextBlock>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Border>
Thanks