Hi all,How to do disappear or appear the graphics (symbol) of Map from legend?Here's what I've done:I added in the LegendItemTemplate the CheckBox.
<Setter Property="LegendItemTemplate">
<Setter.Value>
<DataTemplate>
<StackPanel Orientation="Horizontal" Margin="5,-1,0,-1">
<Grid VerticalAlignment="Center">
<CheckBox x:Name="ChckBoxLayer" IsChecked="{Binding IsEnabled, Mode=TwoWay}" />
<CheckBox IsChecked="{Binding IsEnabled}" IsEnabled="{Binding IsVisible}" IsHitTestVisible="False" />
</Grid>
<Image Source="{Binding ImageSource}" HorizontalAlignment="Left" VerticalAlignment="Center"
Stretch="None" MaxHeight="55" MaxWidth="55" MinWidth="20" Margin="0,-1" />
<TextBlock Text="{Binding Label}" Margin="8,0,0,0" VerticalAlignment="Center" />
</StackPanel>
</DataTemplate>
</Setter.Value>
</Setter>
After I added the event in LegendItemViewModel.private bool _isEnabled = true;
/// <summary>
/// Whether the layer is currently enabled i.e. is checked on.
/// </summary>
/// <value><c>true</c> if the layer is currently enabled; otherwise, <c>false</c>.</value>
public bool IsEnabled
{
get
{
return _isEnabled;
}
set
{
if (value != _isEnabled)
{
_isEnabled = value;
// here the action...
OnPropertyChanged("IsEnabled");
}
}
}
public event PropertyChangedEventHandler PropertyChanged;
internal void OnPropertyChanged(string propertyName)
{
PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
if (propertyChanged != null)
propertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
Thank you in advance,Fabiano