Select to view content in your preferred language

Legend with Templates sample

932
6
07-15-2011 08:05 AM
MichaelKohler
Frequent Contributor
We implemented the Legend with templates sample in our app. Is there any way to remove the opacity from certain layers? I would like to have it availble for only certain feature classes not all of them.
0 Kudos
6 Replies
DominiqueBroux
Esri Frequent Contributor

I would like to have it availble for only certain feature classes not all of them.


You can initialize by code the tag property with the expected visibility for the opacity slider:
private void Legend_Refreshed(object sender, Legend.RefreshedEventArgs e)
{
e.LayerItem.Tag= IsOpacityNeeded(e.LayerItem.Layer) ? Visibility.Visible : Viisbility.Collapsed ;
}


Then you can retemplate the maplayeritem to use the Tag as slider visibility:
<Slider Maximum="1" Value="{Binding Layer.Opacity, Mode=TwoWay}" Width="50" VerticalAlignment="Center"
     Visibility="{Binding Tag}" />
0 Kudos
MichaelKohler
Frequent Contributor
I'm assuming that the IsOpacityNeeded is a function that will return Visibility.Visible or .Collapsed if it's needed. Right?

But, my main problem is in the Legend_Refreshed section, I get an error for e.LayerItem.Tag saying LayerItemViewModel does not contain a definition for Tag...

I would have assumed that I could set a Tag property in the xaml when I add a map layer to the MapControl but there is no Tag property there either.
0 Kudos
DominiqueBroux
Esri Frequent Contributor
I'm assuming that the IsOpacityNeeded is a function that will return Visibility.Visible or .Collapsed if it's needed. Right?


Right. Actually, it just returns true or false but Visible or Collapsed is OK as well.


But, my main problem is in the Legend_Refreshed section, I get an error for e.LayerItem.Tag saying LayerItemViewModel does not contain a definition for Tag...

Which ArcGIS SL version are you using? I think the Tag property has been added in 2.2.
0 Kudos
MichaelKohler
Frequent Contributor
I'm using 2.2.

I just got off of a chat session with an ESRI tech and they couldn't get the .Tag to be recgonized either.

It shows up in the help documentation as being available at http://help.arcgis.com/en/webapi/silverlight/apiref/ESRI.ArcGIS.Client.Toolkit~ESRI.ArcGIS.Client.To...

But neither of us could get it to work.

How can I tell for sure what API version I'm using. If I look at the references in my VS project for ESRI.ArcGIS.Client, it says version 2.1.0.446
0 Kudos
DominiqueBroux
Esri Frequent Contributor

How can I tell for sure what API version I'm using. If I look at the references in my VS project for ESRI.ArcGIS.Client, it says version 2.1.0.446


You are using the 2.1 version, so that explains you don't see the Tag property.

The version should be 2.2.0.629.

If you already installed the 2.2 version, check that your project is referencing the dlls under %programfiles%/ESRI SDKs/Silverlight/v2.2
0 Kudos
MichaelKohler
Frequent Contributor
Sometimes I feel like such an idiot! THANKS! Working fine now.
0 Kudos