Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7046557
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:39:53+00:00 2026-05-28T02:39:53+00:00

Hi I have the following code, the filter call back gets called but the

  • 0

Hi I have the following code, the filter call back gets called but the result call back doesn’t, I’ve been looking at this for some time, any help would be appreciated.

   public HitTestFilterBehavior MyHitTestFilter(DependencyObject o)
   {
        s += o.ToString() + " ";
        //Test for the object value you want to filter.
        if (o.GetType() != typeof(Node))
        {
            // Visual object and descendants are NOT part of hit test results enumeration.
            return HitTestFilterBehavior.ContinueSkipSelf;
        }
        else
        {
            s+="node detected ";
            // Visual object is part of hit test results enumeration.
            return HitTestFilterBehavior.Continue;
        }
    }

Here is the code for the result callback:

public HitTestResultBehavior MyHitTestResult(HitTestResult result)
{
       s += "in result callback ";
       if (result.VisualHit.GetType() == typeof(Node))
        {
            hitResultsList.Add(result.VisualHit as Node);
            s+= "node detected in result callback "
            return HitTestResultBehavior.Stop;

        }
        return HitTestResultBehavior.Continue;
 }

Here is how i am a calling the hit test:

 hitResultsList.Clear();
        VisualTreeHelper.HitTest(designerCanvas, new HitTestFilterCallback(MyHitTestFilter), new HitTestResultCallback(MyHitTestResult), new PointHitTestParameters(End));

Now, the filter callback is going through all the elements and finds the node, however the result callback doesn’t get called at all.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T02:39:53+00:00Added an answer on May 28, 2026 at 2:39 am

    The MSDN doc on “Hit Testing in the Visual Layer” contains the strange Note “The hit test filter callback will sometimes be called in cases where the hit test results callback is not called.” without further explanation why: http://msdn.microsoft.com/en-us/library/ms752097.aspx#using_a_hit_test_filter_callback

    This is because afaik the filter callback is called for the entire visual tree (of designerCanvas), whereas the result callback is only called for those visuals that really got hit by the PointHitTestParameters in question.

    If you really only want to find the first Node (as you return HitTestResultBehavior.Stop when it’s found), you don’t need to filter anyway.

    Try leaving out the filter callback to see if Node is really hit. Call

    VisualTreeHelper.HitTest(designerCanvas, null, MyHitTestResult, new PointHitTestParameters(End));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code in my index view. latest_entry_list = Entry.objects.filter(is_published=True).order_by('-date_published')[:10] for entry
i have the following code in an asp.net mvc view. <% = Html.DropDownList(Filter, new
We have following code: try { // some code throwing MyException } catch (MyException
Helo, i have the following code which should filter entities. Half of the code
I have the following jquery code to call a webmethod in an aspx page
Hi I have this following code with jquery , so it will alternate colors
I have the following (sample)code to filter search results from a LLBLGen data source:
I Have following code: Controller: public ActionResult Step1() { return View(); } [AcceptVerbs(HttpVerbs.Post)] public
I have following Code Block Which I tried to optimize in the Optimized section
I have following code in my application: // to set tip - photo in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.