<?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: Feature layer dynamic query features display in ArcGIS API for Silverlight Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/feature-layer-dynamic-query-features-display/m-p/180916#M4502</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks Jennifer!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;You did it!&amp;nbsp; It was the "FeatureLayer.Update()" line that did it.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;In my query, I leave out types = 14 in order to show on screen only types = 11.&amp;nbsp; The type 14 is on screen already; then, I issue a run-time query from code-behind and retrieve types = 11.&amp;nbsp; The whole idea is to remove the 14s from the screen and place the 11s instead.&amp;nbsp; It works!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I did have to add the "FeatureLayer_UpdateFailed" event in order for the "FeatureLayer_UpdateCompleted" event to execute; the latter was not executing without the former.&amp;nbsp; I use the "FeatureLayer_UpdateCompleted" event for further processing of those newly retrieved features.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The whole process is like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;1.&amp;nbsp; Retrieve types 14 at page first load (XAML):&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;lt;esri:FeatureLayer ID="MyMeters" Renderer="{StaticResource AlertTypesRenderer}" OutFields="*" Where="AlertType = 14" Url="my-url" MouseLeftButtonDown="FeatureLayer_MouseLeftButtonDown" /&amp;gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;2. Bind the feature data grid to the feature layer (XAML):&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;lt;esri:FeatureDataGrid&amp;nbsp; x:Name="MyDataGrid" Map="{Binding ElementName=MyMap}"
GraphicsLayer="{Binding ElementName=MyMap, Path=Layers.[MyMeters]}" SelectionChanged="MyDataGrid_SelectionChanged" /&amp;gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;3. At run-time, perform another query to retrieve types = 11 and remove from screen the 14s that were retrieved at page load with XAML code (cf. step 1):&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;public void ReLoadMeters()
{
&amp;nbsp;&amp;nbsp; // Create an instance referencing the already existing feature layer
&amp;nbsp;&amp;nbsp; FeatureLayer fs = MyMap.Layers["MyMeters"] as FeatureLayer;
&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; // Set event handler on feature layer feature retrieval.
&amp;nbsp;&amp;nbsp; fs.UpdateCompleted += FeatureLayer_UpdateCompleted;
&amp;nbsp;&amp;nbsp; fs.UpdateFailed += new EventHandler&amp;lt;Tasks.TaskFailedEventArgs&amp;gt;(FeatureLayer_UpdateFailed);
&amp;nbsp;&amp;nbsp; fs.Where = "AlertTypes = 11";
&amp;nbsp;&amp;nbsp; fs.Update();
}&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;4.&amp;nbsp; Define the "FeatureLayer_UpdateCompleted" event for further processing of newly retrieved features:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;private void FeatureLayer_UpdateCompleted(object sender, EventArgs args)
{
&amp;nbsp;&amp;nbsp; FeatureLayer fs = sender as FeatureLayer;
&amp;nbsp;&amp;nbsp; foreach (Graphic graphic in fs.Graphics)
&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Here I do my further processing with the newly retrieved features
&amp;nbsp; }
}&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;5.&amp;nbsp; Define the "FeatureLayer_UpdateFailed" event handler (the event at step 4 was not firing without this one):&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;private void FeatureLayer_UpdateFailed(object sender, EventArgs args)
{
&amp;nbsp;&amp;nbsp; FeatureLayer fs = sender as FeatureLayer;
&amp;nbsp;&amp;nbsp; // Catch any errors here...
}&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Now, my feature data grid and the features on screen are in syn all the time: the attributes for those features on screen are listed on the feature data grid; when I click on a map feature or on a row, the map zooms in to the feature and the row highlights.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks again, Jennifer!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Hugo.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 09:14:48 GMT</pubDate>
    <dc:creator>HugoCardenas</dc:creator>
    <dc:date>2021-12-11T09:14:48Z</dc:date>
    <item>
      <title>Feature layer dynamic query features display</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/feature-layer-dynamic-query-features-display/m-p/180914#M4500</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Is there a way to display new sets of features on the map without deleting existing or currently diplayed ones?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Initially, when the page loads for the first time, I display on screen a set of features (cf. XAML code below):&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;&amp;lt;esri:FeatureLayer ID="MyMeters" Renderer="{StaticResource AlertTypesRenderer}" Where="AlertType = 14" ... /&amp;gt;&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;At run time, the user has a set of check boxes to display any other alerts and remove from the screen the previously loaded ones (cf. C# code bewlow):&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;ESRI.ArcGIS.Client.FeatureLayer fs = new ESRI.ArcGIS.Client.FeatureLayer();
fs.Where = "AlertType = 11";&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;At this point, the user has checked-off the "14" and checked the "11" alerts.&amp;nbsp; If I call a "ClearGraphics" method on the feature layer right before displaying the new features, "ClearGraphics" actually deletes the previous features permanently from the feature service!&amp;nbsp; Hence, I create a new instance of the "FeatureLayer" (cf. C# code above), rather than referencing the existing instance like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;FeatureLayer fs = MyMap.Layers["MyMeters"] as FeatureLayer;&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have tried other options like:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;1.&amp;nbsp; Removing the entire MyMap.Layers["MyMeters"] and inserting a new one (in the same index position as that of the previous one) with the new features.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;2. Creating a new graphics layers and add this one to the MyMap.Layers collection.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;These two options work fine, BUT my feature data grid gets all crazy: in option 1 the feature data grid references the feature layer that is removed.&amp;nbsp; When I bind the new layer at run-time to it, it does not sync that well. In option 2, the feature data grid does not respond at all.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Perhaps I am managing the features of a feature layer the wrong way.&amp;nbsp; I think there may be a way to just "hide" or remove previous features from screen, so I can only see on screen the new ones.&amp;nbsp; In doing, so I can choose to display only the features I specify, without having to "delete" them form the Service, or without having to "remove/insert" feature layers.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Do you know any better way?&amp;nbsp; Please share it with me.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hugo.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Oct 2011 15:05:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/feature-layer-dynamic-query-features-display/m-p/180914#M4500</guid>
      <dc:creator>HugoCardenas</dc:creator>
      <dc:date>2011-10-03T15:05:13Z</dc:date>
    </item>
    <item>
      <title>Re: Feature layer dynamic query features display</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/feature-layer-dynamic-query-features-display/m-p/180915#M4501</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;How about updating the FeatureLayer.Where clause to include previous clause?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;WHERE = "AlertType = 14 or AlertType = 11"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Calling FeatureLayer.Update() will query the service and return features that match the above condition.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Oct 2011 19:49:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/feature-layer-dynamic-query-features-display/m-p/180915#M4501</guid>
      <dc:creator>JenniferNery</dc:creator>
      <dc:date>2011-10-03T19:49:08Z</dc:date>
    </item>
    <item>
      <title>Re: Feature layer dynamic query features display</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/feature-layer-dynamic-query-features-display/m-p/180916#M4502</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks Jennifer!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;You did it!&amp;nbsp; It was the "FeatureLayer.Update()" line that did it.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;In my query, I leave out types = 14 in order to show on screen only types = 11.&amp;nbsp; The type 14 is on screen already; then, I issue a run-time query from code-behind and retrieve types = 11.&amp;nbsp; The whole idea is to remove the 14s from the screen and place the 11s instead.&amp;nbsp; It works!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I did have to add the "FeatureLayer_UpdateFailed" event in order for the "FeatureLayer_UpdateCompleted" event to execute; the latter was not executing without the former.&amp;nbsp; I use the "FeatureLayer_UpdateCompleted" event for further processing of those newly retrieved features.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The whole process is like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;1.&amp;nbsp; Retrieve types 14 at page first load (XAML):&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;lt;esri:FeatureLayer ID="MyMeters" Renderer="{StaticResource AlertTypesRenderer}" OutFields="*" Where="AlertType = 14" Url="my-url" MouseLeftButtonDown="FeatureLayer_MouseLeftButtonDown" /&amp;gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;2. Bind the feature data grid to the feature layer (XAML):&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;lt;esri:FeatureDataGrid&amp;nbsp; x:Name="MyDataGrid" Map="{Binding ElementName=MyMap}"
GraphicsLayer="{Binding ElementName=MyMap, Path=Layers.[MyMeters]}" SelectionChanged="MyDataGrid_SelectionChanged" /&amp;gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;3. At run-time, perform another query to retrieve types = 11 and remove from screen the 14s that were retrieved at page load with XAML code (cf. step 1):&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;public void ReLoadMeters()
{
&amp;nbsp;&amp;nbsp; // Create an instance referencing the already existing feature layer
&amp;nbsp;&amp;nbsp; FeatureLayer fs = MyMap.Layers["MyMeters"] as FeatureLayer;
&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; // Set event handler on feature layer feature retrieval.
&amp;nbsp;&amp;nbsp; fs.UpdateCompleted += FeatureLayer_UpdateCompleted;
&amp;nbsp;&amp;nbsp; fs.UpdateFailed += new EventHandler&amp;lt;Tasks.TaskFailedEventArgs&amp;gt;(FeatureLayer_UpdateFailed);
&amp;nbsp;&amp;nbsp; fs.Where = "AlertTypes = 11";
&amp;nbsp;&amp;nbsp; fs.Update();
}&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;4.&amp;nbsp; Define the "FeatureLayer_UpdateCompleted" event for further processing of newly retrieved features:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;private void FeatureLayer_UpdateCompleted(object sender, EventArgs args)
{
&amp;nbsp;&amp;nbsp; FeatureLayer fs = sender as FeatureLayer;
&amp;nbsp;&amp;nbsp; foreach (Graphic graphic in fs.Graphics)
&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Here I do my further processing with the newly retrieved features
&amp;nbsp; }
}&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;5.&amp;nbsp; Define the "FeatureLayer_UpdateFailed" event handler (the event at step 4 was not firing without this one):&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;private void FeatureLayer_UpdateFailed(object sender, EventArgs args)
{
&amp;nbsp;&amp;nbsp; FeatureLayer fs = sender as FeatureLayer;
&amp;nbsp;&amp;nbsp; // Catch any errors here...
}&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Now, my feature data grid and the features on screen are in syn all the time: the attributes for those features on screen are listed on the feature data grid; when I click on a map feature or on a row, the map zooms in to the feature and the row highlights.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks again, Jennifer!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Hugo.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 09:14:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/feature-layer-dynamic-query-features-display/m-p/180916#M4502</guid>
      <dc:creator>HugoCardenas</dc:creator>
      <dc:date>2021-12-11T09:14:48Z</dc:date>
    </item>
  </channel>
</rss>

