<?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: FindGraphicsInHostCoordinates problem in ArcGIS API for Silverlight Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/findgraphicsinhostcoordinates-problem/m-p/586209#M15019</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;So I answer my own question...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It appears there is a bug in the WPF API for the FindGraphicsInHostCoordinates (WPF API Version: 2.4.0.851).&amp;nbsp; (If it's not a bug, then it's not documented to have the following characteristics)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;After tracking the down the documentation on the WPF version of &lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/en/webapi/wpf/apiref/ESRI.ArcGIS.Client~ESRI.ArcGIS.Client.GraphicsLayer~FindGraphicsInHostCoordinates(Rect).html" rel="nofollow noopener noreferrer" target="_blank"&gt;FindGraphicsInHostCoordinates &lt;/A&gt;&lt;SPAN&gt;, I noticed the API says it's exepecting a &lt;/SPAN&gt;&lt;A href="http://msdn.microsoft.com/query/dev10.query?appId=Dev10IDEF1&amp;amp;l=EN-US&amp;amp;k=k(System.Windows.Rect);k(TargetFrameworkMoniker-WPF,VERSION=V4.0)&amp;amp;rd=true" rel="nofollow noopener noreferrer" target="_blank"&gt;Rect&lt;/A&gt;&lt;SPAN&gt; for the input parameters.&amp;nbsp; Passing in a point or a Rect with a width/height of 0 will only return the topmost graphic.&amp;nbsp; So the fix is to create a rectangle out of the clicked point relative to the application.&amp;nbsp; Then use the Inflate function to give the rectangle any width/height greater than 0.&amp;nbsp; Here is what the code would look like.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
Point RightMouseButtonDownLocation = e.GetPosition(Application.Current.MainWindow);

Rect rect = new Rect(RightMouseButtonDownLocation, RightMouseButtonDownLocation);
rect.Inflate(1,1); //THE FIX -inflate making the box 1px x 1px

var graphics = MyFeatureLayer.FindGraphicsInHostCoordinates(rect);

&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hope this helps.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 01:12:56 GMT</pubDate>
    <dc:creator>JustinCornell</dc:creator>
    <dc:date>2021-12-12T01:12:56Z</dc:date>
    <item>
      <title>FindGraphicsInHostCoordinates problem</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/findgraphicsinhostcoordinates-problem/m-p/586203#M15013</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm trying to use FindGraphicsInHostCoordinates on FeatureLayer after LeftMouseButtonDown on layer feature. The code is as follows:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
Point position = e.ScreenPoint;
FeatureLayer featureLayer = MyMap.Layers["Stops"] as FeatureLayer;
IEnumerable&amp;lt;Graphic&amp;gt; clickedFeatures = featureLayer.FindGraphicsInHostCoordinates(position);
MessageBox.Show(clickedFeatures.Count().ToString());
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Everything goes OK when I zoom on the map, but when I pan to new location and click on the feature I got an number of features '0'. When I zoom out or in and click that feature again, I got '1' which is of course correct.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What is the problem here? I firstly thought that problem is that layer property Mode was set to "OnDemand" so I switched to "Snapshot" but it hadn't helped. Thanks for help.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Filip&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Dec 2010 10:04:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/findgraphicsinhostcoordinates-problem/m-p/586203#M15013</guid>
      <dc:creator>FilipJung</dc:creator>
      <dc:date>2010-12-03T10:04:12Z</dc:date>
    </item>
    <item>
      <title>Re: FindGraphicsInHostCoordinates problem</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/findgraphicsinhostcoordinates-problem/m-p/586204#M15014</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I guess you missed the transformation to host coordinates.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Please look at Morten's answer in this thread : &lt;/SPAN&gt;&lt;A href="http://forums.arcgis.com/threads/3093-Graphic-Selection-based-on-Draw-Envelope-issue"&gt;http://forums.arcgis.com/threads/3093-Graphic-Selection-based-on-Draw-Envelope-issue&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Dec 2010 14:43:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/findgraphicsinhostcoordinates-problem/m-p/586204#M15014</guid>
      <dc:creator>DominiqueBroux</dc:creator>
      <dc:date>2010-12-03T14:43:49Z</dc:date>
    </item>
    <item>
      <title>Re: FindGraphicsInHostCoordinates problem</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/findgraphicsinhostcoordinates-problem/m-p/586205#M15015</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;I guess you missed the transformation to host coordinates.&lt;BR /&gt;Please look at Morten's answer in this thread : &lt;A href="http://forums.arcgis.com/threads/3093-Graphic-Selection-based-on-Draw-Envelope-issue" rel="nofollow noopener noreferrer" target="_blank"&gt;http://forums.arcgis.com/threads/3093-Graphic-Selection-based-on-Draw-Envelope-issue&lt;/A&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I've looked at suggested post and tried following:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;Point position = e.ScreenPoint;
Point screenPointRelativeToHost = MyMap.TransformToVisual(Application.Current.RootVisual).Transform(position);&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But 'position' and 'screenPointRelativeToHost' return the same coords. How can I get the right coords? They are right returned when I use: Point pos = args.GetPosition(MyMap); after clicking on FeatureLayer. Can I get right coords when clicking in the map after panning? &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I want to solve situation, where graphic lies on features (dynamic layer) that are in identify task, but I don't want to execute identify task, if there is graphic in click location.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 01:12:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/findgraphicsinhostcoordinates-problem/m-p/586205#M15015</guid>
      <dc:creator>FilipJung</dc:creator>
      <dc:date>2021-12-12T01:12:46Z</dc:date>
    </item>
    <item>
      <title>Re: FindGraphicsInHostCoordinates problem</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/findgraphicsinhostcoordinates-problem/m-p/586206#M15016</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Are you using Silveright, WPF or WP7?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This should work for Silverlight:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
GraphicsLayer graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer;&amp;nbsp; 
GeneralTransform generalTransform = MyMap.TransformToVisual(Application.Current.RootVisual);
System.Windows.Point transformScreenPnt = generalTransform.Transform(e.GetPosition(this.MyMap));
var graphics = graphicsLayer.FindGraphicsInHostCoordinates(transformScreenPnt);
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The following examples demonstrate the use of FindGraphicsInHostCoordinates:&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#InfoWindowSimple" rel="nofollow noopener noreferrer" target="_blank"&gt;http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#InfoWindowSimple&lt;/A&gt;&lt;BR /&gt;&lt;A href="http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#Offset" rel="nofollow noopener noreferrer" target="_blank"&gt;http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#Offset&lt;/A&gt;&lt;BR /&gt;&lt;A href="http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#Reshape" rel="nofollow noopener noreferrer" target="_blank"&gt;http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#Reshape&lt;/A&gt;&lt;BR /&gt;&lt;A href="http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#Union" rel="nofollow noopener noreferrer" target="_blank"&gt;http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#Union&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 01:12:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/findgraphicsinhostcoordinates-problem/m-p/586206#M15016</guid>
      <dc:creator>JenniferNery</dc:creator>
      <dc:date>2021-12-12T01:12:49Z</dc:date>
    </item>
    <item>
      <title>Re: FindGraphicsInHostCoordinates problem</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/findgraphicsinhostcoordinates-problem/m-p/586207#M15017</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm using Silverlight. I've used code used in webapi example and it works fine:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
MapPoint pointInMap= e.MapPoint;
Point clickPosition= MyMap.MapToScreen(pointInMap);
GeneralTransform generalTransform = MyMap.TransformToVisual(Application.Current.RootVisual);
Point transformScreenPnt = generalTransform.Transform(clickPosition);
var graphics = graphicsLayer.FindGraphicsInHostCoordinates(transformScreenPnt);
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks very much for Your help, it really helped me much solving my issue. Next time I should carefully check all examples in webapi &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 01:12:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/findgraphicsinhostcoordinates-problem/m-p/586207#M15017</guid>
      <dc:creator>FilipJung</dc:creator>
      <dc:date>2021-12-12T01:12:51Z</dc:date>
    </item>
    <item>
      <title>Re: FindGraphicsInHostCoordinates problem</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/findgraphicsinhostcoordinates-problem/m-p/586208#M15018</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi, I am using WPF and I trying the same thing, however,&amp;nbsp; I can only get the top most graphic returned.&amp;nbsp; Is there something different about silverlight than WPF?&amp;nbsp; Here is what I have tried and they both return to me on the top most graphic when I need all stacked graphics. (I am using version 2.4.0.851 of the API) If you have some code that will return all graphics please post.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;

//only returns the top most graphic
System.Windows.Media.GeneralTransform generalTransform = MyMap.TransformToVisual(Application.Current.MainWindow);
Point RightMouseButtonDownLocation = generalTransform.Transform(e.GetPosition(MyMap));

var graphics = MyFeatureLayer.FindGraphicsInHostCoordinates(RightMouseButtonDownLocation).ToList();


///----------- TRIED THIS WAY TOO -----------
//only returns the top most graphic
Point RightMouseButtonDownLocation = e.GetPosition(Application.Current.MainWindow);
var graphics = MyFeatureLayer.FindGraphicsInHostCoordinates(RightMouseButtonDownLocation).ToList();

&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any help would be appreciated.&amp;nbsp; Thanks!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 01:12:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/findgraphicsinhostcoordinates-problem/m-p/586208#M15018</guid>
      <dc:creator>JustinCornell</dc:creator>
      <dc:date>2021-12-12T01:12:54Z</dc:date>
    </item>
    <item>
      <title>Re: FindGraphicsInHostCoordinates problem</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/findgraphicsinhostcoordinates-problem/m-p/586209#M15019</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;So I answer my own question...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It appears there is a bug in the WPF API for the FindGraphicsInHostCoordinates (WPF API Version: 2.4.0.851).&amp;nbsp; (If it's not a bug, then it's not documented to have the following characteristics)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;After tracking the down the documentation on the WPF version of &lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/en/webapi/wpf/apiref/ESRI.ArcGIS.Client~ESRI.ArcGIS.Client.GraphicsLayer~FindGraphicsInHostCoordinates(Rect).html" rel="nofollow noopener noreferrer" target="_blank"&gt;FindGraphicsInHostCoordinates &lt;/A&gt;&lt;SPAN&gt;, I noticed the API says it's exepecting a &lt;/SPAN&gt;&lt;A href="http://msdn.microsoft.com/query/dev10.query?appId=Dev10IDEF1&amp;amp;l=EN-US&amp;amp;k=k(System.Windows.Rect);k(TargetFrameworkMoniker-WPF,VERSION=V4.0)&amp;amp;rd=true" rel="nofollow noopener noreferrer" target="_blank"&gt;Rect&lt;/A&gt;&lt;SPAN&gt; for the input parameters.&amp;nbsp; Passing in a point or a Rect with a width/height of 0 will only return the topmost graphic.&amp;nbsp; So the fix is to create a rectangle out of the clicked point relative to the application.&amp;nbsp; Then use the Inflate function to give the rectangle any width/height greater than 0.&amp;nbsp; Here is what the code would look like.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
Point RightMouseButtonDownLocation = e.GetPosition(Application.Current.MainWindow);

Rect rect = new Rect(RightMouseButtonDownLocation, RightMouseButtonDownLocation);
rect.Inflate(1,1); //THE FIX -inflate making the box 1px x 1px

var graphics = MyFeatureLayer.FindGraphicsInHostCoordinates(rect);

&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hope this helps.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 01:12:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/findgraphicsinhostcoordinates-problem/m-p/586209#M15019</guid>
      <dc:creator>JustinCornell</dc:creator>
      <dc:date>2021-12-12T01:12:56Z</dc:date>
    </item>
  </channel>
</rss>

