<?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: Define Graphics Selection Style at runtime? in ArcGIS API for Silverlight Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/define-graphics-selection-style-at-runtime/m-p/477121#M12304</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;In that sample, the symbols with control template are part of Resources. They define VisualStates for Selected and Unselected states. If the Graphic.Symbol uses a symbol such as the ones in that sample then at run-time, all that you have to do is update the Graphic.Selected property. I think this is the cleanest approach, you don't need XamlLoader.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You can also define a Renderer that use one of these symbols and apply that to your GraphicsLayer so you would not need to set each Graphic's Symbol as in that example.&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
&amp;lt;!-- place this under resources --&amp;gt;
&amp;lt;esri:SimpleRenderer x:Key="MySimpleRenderer" Symbols ="{StaticResource SelectMarkerSymbol}"/&amp;gt;
&amp;lt;!-- place this under Map.layers--&amp;gt;
&amp;lt;esri:GraphicsLayer ID="MyGraphicsLayer" Renderer="{StaticResource MySimpleRenderer}"/&amp;gt;
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you need to access these resources in code, you can do this&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;Symbol symbol = LayoutRoot.Resources["SelectMarkerSymbol"] as Symbol;
Renderer renderer = LayoutRoot.Resources["MySimpleRenderer"] as Renderer;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 21:04:50 GMT</pubDate>
    <dc:creator>JenniferNery</dc:creator>
    <dc:date>2021-12-11T21:04:50Z</dc:date>
    <item>
      <title>Define Graphics Selection Style at runtime?</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/define-graphics-selection-style-at-runtime/m-p/477120#M12303</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm new to Silverlight, but trying to figure out the cleanest way to define Graphics selection style at runtime.&amp;nbsp; The &lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/en/webapi/silverlight/2.1/samples/start.htm#SelectGraphics"&gt;Selections&lt;/A&gt;&lt;SPAN&gt; example seems to indicate that this is done with control-templates.&amp;nbsp; It seems that defining control-templates at runtime requires XamlLoader - a rather inelegant solution.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I was hoping that someone could post an example to show me a cleaner way.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks in advance!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Jan 2011 03:04:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/define-graphics-selection-style-at-runtime/m-p/477120#M12303</guid>
      <dc:creator>JoeShmoe</dc:creator>
      <dc:date>2011-01-25T03:04:53Z</dc:date>
    </item>
    <item>
      <title>Re: Define Graphics Selection Style at runtime?</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/define-graphics-selection-style-at-runtime/m-p/477121#M12304</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;In that sample, the symbols with control template are part of Resources. They define VisualStates for Selected and Unselected states. If the Graphic.Symbol uses a symbol such as the ones in that sample then at run-time, all that you have to do is update the Graphic.Selected property. I think this is the cleanest approach, you don't need XamlLoader.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You can also define a Renderer that use one of these symbols and apply that to your GraphicsLayer so you would not need to set each Graphic's Symbol as in that example.&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
&amp;lt;!-- place this under resources --&amp;gt;
&amp;lt;esri:SimpleRenderer x:Key="MySimpleRenderer" Symbols ="{StaticResource SelectMarkerSymbol}"/&amp;gt;
&amp;lt;!-- place this under Map.layers--&amp;gt;
&amp;lt;esri:GraphicsLayer ID="MyGraphicsLayer" Renderer="{StaticResource MySimpleRenderer}"/&amp;gt;
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you need to access these resources in code, you can do this&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;Symbol symbol = LayoutRoot.Resources["SelectMarkerSymbol"] as Symbol;
Renderer renderer = LayoutRoot.Resources["MySimpleRenderer"] as Renderer;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 21:04:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/define-graphics-selection-style-at-runtime/m-p/477121#M12304</guid>
      <dc:creator>JenniferNery</dc:creator>
      <dc:date>2021-12-11T21:04:50Z</dc:date>
    </item>
    <item>
      <title>Re: Define Graphics Selection Style at runtime?</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/define-graphics-selection-style-at-runtime/m-p/477122#M12305</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I thought about my ControlTemplate issue and realized I hadn't defined my problem fully. I didn't need custom properties.&amp;nbsp; I just didn't want my ControlTemplate XAML living stuck in some &amp;lt;resources&amp;gt; tag in some parent container.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Easy fix: I wrapped my custom ControlTemplate with a ResourceDictionary tag and put it into its own XAML file, similar to how styles are defined.&amp;nbsp; I load the ResourceDictionary via code, so users don't have to muck around with merging this dictionary in.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;SimpleMarkerSymbol symbol = new SimpleMarkerSymbol {Color = brush, Size = 8};&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;MyCustomResourceDictionary dictionary = new MyCustomResourceDictionary ();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ControlTemplate controlTemplate = (ControlTemplate)dictionary["SelectableMarkerSymbolTemplate"];&amp;nbsp;&amp;nbsp; symbol.ControlTemplate = controlTemplate;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I can see two other alternative solutions to my problem.&amp;nbsp; The most obvious is to simply create an alternative Symbol classes / XAML to use, which include any missing attributes.&amp;nbsp; Another option might be to nest a ContentControl/ContentPresenter inside the Symbol's ControlTemplate, and bind that to a custom visualization.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Jan 2011 16:14:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/define-graphics-selection-style-at-runtime/m-p/477122#M12305</guid>
      <dc:creator>JoeShmoe</dc:creator>
      <dc:date>2011-01-26T16:14:31Z</dc:date>
    </item>
    <item>
      <title>Re: Define Graphics Selection Style at runtime?</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/define-graphics-selection-style-at-runtime/m-p/477123#M12306</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;XamlReader.Load is actually not that inelegant (apart from building the string of course). Creating a complex UI using XamlReader is faster than "building" it up using UI Elements one by one.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Anyway I'm glad you went the resourcedictionary route. Its the best way to do it. You might want to consider optimizing it a bit so you only load the resource dictionary the first time you need it, and reuse it after that.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Jan 2011 19:55:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/define-graphics-selection-style-at-runtime/m-p/477123#M12306</guid>
      <dc:creator>dotMorten_esri</dc:creator>
      <dc:date>2011-01-26T19:55:50Z</dc:date>
    </item>
  </channel>
</rss>

