This is a migrated thread and some comments may be shown as answers.

SilverlightApp ElementsFromPoint

3 Answers 40 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Jason
Top achievements
Rank 1
Jason asked on 17 Sep 2012, 07:46 PM
Is there a known issue for this method? I am finding that it only returns elements found in the VisualTree.Root. Meaning that if there are any Popups active/visible, they will not be included in the ElementsFromPoint return list. In this way it is not truly returning all available elements at the given point. Please advise.

3 Answers, 1 is accepted

Sort by
0
Plamen
Telerik team
answered on 20 Sep 2012, 01:38 PM
Hello Jason,

You're correct. The current implementation of this method returns only the elements contained in the VisualTree.Root. I filed a bug on this. You can track its progress and vote for the PITS Issue here: Public URL.

I've also updated your Telerik points for bringing this to our attention.

Regards,
Plamen
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
0
Jason
Top achievements
Rank 1
answered on 20 Sep 2012, 04:09 PM
Thanks Plamen,

Until the fix is implemented I have worked around the issue using the following in the case of Popups...
... pseudo ...
if ( app.Popups.Count > 0 )
{
   currentElements = FindElementsFromPoint( p, app.Popups[ index ].VisualTree.Root );
}
... pseudo ... 


 
public List<FrameworkElement> FindElementsFromPoint( System.Drawing.Point point, FrameworkElement rootFrameworkElement )
{
    List<FrameworkElement> frameworkElementList = new List<FrameworkElement>();
    SearchElementsForPoint( point, rootFrameworkElement, frameworkElementList );
    return frameworkElementList;
}
 
public void SearchElementsForPoint( System.Drawing.Point point, FrameworkElement frameworkElement, List<FrameworkElement> frameworkElementList )
{
    if ( frameworkElement != null )
    {
        if ( frameworkElement.GetRectangle().Contains( point ) )
        {
            frameworkElementList.Add( frameworkElement );
        }
 
        if ( frameworkElement.Children != null )
        {
            foreach ( FrameworkElement child in frameworkElement.Children )
            {
                if ( child != null )
                {
                    SearchElementsForPoint( point, child, frameworkElementList );
                }
            }
        }
    }
}


I look forward to the fix as this is computationally expensive :)


0
Plamen
Telerik team
answered on 21 Sep 2012, 11:47 AM
Hi Jason,

That is excellent! I am glad to hear you found a workable workaround on your own. I really appreciate the update and hope to have this bug fixed soon.

All the best,
Plamen
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
Tags
General Discussions
Asked by
Jason
Top achievements
Rank 1
Answers by
Plamen
Telerik team
Jason
Top achievements
Rank 1
Share this question
or