Select to view content in your preferred language

How to do disappear or appear the graphics (symbol) of Map from legend?

1357
11
12-18-2012 06:51 AM
FabienNAPPA
Regular Contributor
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
0 Kudos
11 Replies
FabienNAPPA
Regular Contributor
Thank you Dominique,

I do not know how to do that!

I'm sorry because my English is not perfect and I do not quite understand.

Would you have an example?

Thank you in advance,
Fabiano
0 Kudos
FabienNAPPA
Regular Contributor
Dominique,

I do not know how to do that!

Would you have an example?

Thank you in advance,
Fabiano
0 Kudos