<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Adding check boxes to individual Legend Items to control a feature layer display in ArcGIS API for Silverlight Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/adding-check-boxes-to-individual-legend-items-to/m-p/261948#M6787</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;&amp;lt;esri:Legend.LegendItemTemplate&amp;gt;&lt;BR /&gt;&amp;lt;DataTemplate&amp;gt;&lt;BR /&gt;&amp;lt;CheckBox&amp;gt;&lt;BR /&gt;&lt;BR /&gt;/* HERE IS MY PROBLEM: It places the red marker 3 times, while ignoring the other markers */ &lt;BR /&gt;&lt;BR /&gt;&amp;lt;/CheckBox&amp;gt;&lt;BR /&gt;&amp;lt;/DataTemplate&amp;gt;&lt;BR /&gt;&amp;lt;/esri:Legend.LegendItemTemplate&amp;gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;That should not place the red marker 3 times, but place 3 different legend items.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Now as the template don't display any information about the legend item, I am not sure how you deduce that the same marker is displayed 3 times?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Try with a LegendItemTemplate such as:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;lt;esri:Legend.LegendItemTemplate&amp;gt;
&amp;nbsp; &amp;lt;DataTemplate&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;StackPanel Orientation="Horizontal" Margin="0,-1"&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;CheckBox VerticalAlignment="Center" /&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Image Source="{Binding ImageSource}" HorizontalAlignment="Center" VerticalAlignment="Center" Stretch="None" MinWidth="20" /&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;TextBlock Text="{Binding Label}" Margin="5,0,0,0" VerticalAlignment="Center" /&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/StackPanel&amp;gt;
&amp;nbsp; &amp;lt;/DataTemplate&amp;gt;
&amp;lt;/esri:Legend.LegendItemTemplate&amp;gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You should see 3 different markers.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 12:50:39 GMT</pubDate>
    <dc:creator>DominiqueBroux</dc:creator>
    <dc:date>2021-12-11T12:50:39Z</dc:date>
    <item>
      <title>Adding check boxes to individual Legend Items to control a feature layer display</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/adding-check-boxes-to-individual-legend-items-to/m-p/261947#M6786</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Is there a way to add a check box to each Legend Item to turn on/off a feature layer features?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have a feature service displaying point features using a renderer.&amp;nbsp; The Legend displays three different Legend Items: a red maker [large leaks], a yellow marker [small leaks], and a blue marker [no leaks].&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The Legend XAML does place a check box for the layer, but not for each "Legend Item Template":&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;&amp;lt;esri:Legend x:Name="mapLegend" Map="{Binding ElementName=MyMap}" 
&amp;nbsp; LayerItemsMode="Tree" 
&amp;nbsp; ShowOnlyVisibleLayers="False" 
&amp;nbsp; Refreshed="Legend_Refreshed"&amp;gt;

&amp;nbsp; &amp;lt;esri:Legend.MapLayerTemplate&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;DataTemplate&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;StackPanel Orientation="Horizontal"&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;CheckBox Content="{Binding Label}"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IsChecked="{Binding IsEnabled, Mode=TwoWay}"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IsEnabled="{Binding IsInScaleRange}" &amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/CheckBox&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/StackPanel&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/DataTemplate&amp;gt;
&amp;nbsp; &amp;lt;/esri:Legend.MapLayerTemplate&amp;gt;

&amp;nbsp; &amp;lt;esri:Legend.LayerTemplate&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;DataTemplate&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;CheckBox Content="{Binding Label}"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IsChecked="{Binding IsEnabled, Mode=TwoWay}"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IsEnabled="{Binding IsInScaleRange}" &amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/CheckBox&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/DataTemplate&amp;gt;
&amp;nbsp; &amp;lt;/esri:Legend.LayerTemplate&amp;gt;

/* THE CODE IS FINE UNTIL HERE: I get a nice legend with 3 different markers and their proper Label.&amp;nbsp; */

&amp;nbsp; &amp;lt;esri:Legend.LegendItemTemplate&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;DataTemplate&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;CheckBox&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* HERE IS MY PROBLEM: It places the red marker 3 times, while ignoring the other markers */&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/CheckBox&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/DataTemplate&amp;gt;
&amp;nbsp;&amp;nbsp; &amp;lt;/esri:Legend.LegendItemTemplate&amp;gt;

 &amp;lt;/esri:Legend&amp;gt;
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If I get to add a check box next to each "LegendItemTemplate" then I can control display of my feature service layer from the legend items: &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Display only small leaks --&amp;gt; Check mark the "yellow" marker check box.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Turn off small leaks --&amp;gt; Uncheck the "yellow" marker check box.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;And so forth...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I could then retrieve those features specified by the check box event using code-behind; no problem here.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Has anyone done something similar?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Is this the proper way to achieve this?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Your input is much appreciated.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hugo.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Jan 2012 17:37:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/adding-check-boxes-to-individual-legend-items-to/m-p/261947#M6786</guid>
      <dc:creator>HugoCardenas</dc:creator>
      <dc:date>2012-01-19T17:37:34Z</dc:date>
    </item>
    <item>
      <title>Re: Adding check boxes to individual Legend Items to control a feature layer display</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/adding-check-boxes-to-individual-legend-items-to/m-p/261948#M6787</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;&amp;lt;esri:Legend.LegendItemTemplate&amp;gt;&lt;BR /&gt;&amp;lt;DataTemplate&amp;gt;&lt;BR /&gt;&amp;lt;CheckBox&amp;gt;&lt;BR /&gt;&lt;BR /&gt;/* HERE IS MY PROBLEM: It places the red marker 3 times, while ignoring the other markers */ &lt;BR /&gt;&lt;BR /&gt;&amp;lt;/CheckBox&amp;gt;&lt;BR /&gt;&amp;lt;/DataTemplate&amp;gt;&lt;BR /&gt;&amp;lt;/esri:Legend.LegendItemTemplate&amp;gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;That should not place the red marker 3 times, but place 3 different legend items.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Now as the template don't display any information about the legend item, I am not sure how you deduce that the same marker is displayed 3 times?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Try with a LegendItemTemplate such as:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;lt;esri:Legend.LegendItemTemplate&amp;gt;
&amp;nbsp; &amp;lt;DataTemplate&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;StackPanel Orientation="Horizontal" Margin="0,-1"&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;CheckBox VerticalAlignment="Center" /&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Image Source="{Binding ImageSource}" HorizontalAlignment="Center" VerticalAlignment="Center" Stretch="None" MinWidth="20" /&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;TextBlock Text="{Binding Label}" Margin="5,0,0,0" VerticalAlignment="Center" /&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/StackPanel&amp;gt;
&amp;nbsp; &amp;lt;/DataTemplate&amp;gt;
&amp;lt;/esri:Legend.LegendItemTemplate&amp;gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You should see 3 different markers.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 12:50:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/adding-check-boxes-to-individual-legend-items-to/m-p/261948#M6787</guid>
      <dc:creator>DominiqueBroux</dc:creator>
      <dc:date>2021-12-11T12:50:39Z</dc:date>
    </item>
    <item>
      <title>Re: Adding check boxes to individual Legend Items to control a feature layer display</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/adding-check-boxes-to-individual-legend-items-to/m-p/261949#M6788</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks Dominique!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;It works well.&amp;nbsp; I am impressed.&amp;nbsp; The line that solved my problem is the following:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;&amp;lt;Image Source="{Binding ImageSource}" ... /&amp;gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;I did not know how to bind the "Source" property to the correct icons/images.&amp;nbsp; "ImageSource" took care of it.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The API documentation for the LegendItemTemplate Property states:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Turning on/off individual LegendItems or changing their opacity is not possible on any Layer type. It is possible to get creative and perform TOC style user interactions at the Legend.LegendItemtemplate level by discovering the parent objects of individual LegendItems.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;And this is precisely the approach I will take with the C# code: I will capture the event fired by the checkbox of each item; thus, turn on/off this feature service features on its own attributes.&amp;nbsp; The API documentation has good clues on how to achieve this, unless you are aware of any other approach.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Again, thanks a lot!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Hugo.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Jan 2012 11:22:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/adding-check-boxes-to-individual-legend-items-to/m-p/261949#M6788</guid>
      <dc:creator>HugoCardenas</dc:creator>
      <dc:date>2012-01-20T11:22:06Z</dc:date>
    </item>
    <item>
      <title>Re: Adding check boxes to individual Legend Items to control a feature layer display</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/adding-check-boxes-to-individual-legend-items-to/m-p/261950#M6789</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Thanks Dominique!&lt;BR /&gt;It works well. I am impressed.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks. You are welcome.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;And this is precisely the approach I will take with the C# code: I will capture the event fired by the checkbox of each item; thus, turn on/off this feature service features on its own attributes. The API documentation has good clues on how to achieve this, unless you are aware of any other approach.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt;This approach looks good. I think I already did a sample like that but I don't remember where :confused:.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Let me know if you run into an issue I'll try removing dust from old samples:).&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Jan 2012 11:55:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/adding-check-boxes-to-individual-legend-items-to/m-p/261950#M6789</guid>
      <dc:creator>DominiqueBroux</dc:creator>
      <dc:date>2012-01-20T11:55:15Z</dc:date>
    </item>
  </channel>
</rss>

