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 7797701
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T23:46:08+00:00 2026-06-01T23:46:08+00:00

I have a WPF ParentUserControl and some ChildUserControlA ChildUserControlB etc. (also WPF controls) The

  • 0

I have a WPF ParentUserControl and some ChildUserControlA ChildUserControlB etc. (also WPF controls)

The ChildUserControls are controls containing on them some other basic elements (textboxes, labels, etc)

In the main form’s status bar I need to display the name of the currenlty mouse overed ChildUserControl.

So, in the ParentUserControl‘s MouseMove I obtain an object myElement = Mouse.DirectlyOver because I need the top most of ChildUserControl‘s, but I obtain instead a ‘System.Windows.Controls.TextBlock’ (part of ChildUserControl)…

How to fix that?

I need when I mouseOver an MyChildControl that the MyChildControl be detected, and not its child elements.

In this order I used on MyChildControl the following:

Protected Overrides Function HitTestCore(
                    hitTestParameters As PointHitTestParameters) As HitTestResult

    Return New PointHitTestResult(Me, hitTestParameters.HitPoint)
End Function

but anyway I get sometimes the textblock as result, sometimes the ChildUserControl…

  • 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-06-01T23:46:09+00:00Added an answer on June 1, 2026 at 11:46 pm

    Another answer may be something like this – define the exact types of objects you care about and work up the visual tree until you find them :

    Private myTypes As New List(Of Type)()
    Public Sub New()
        InitializeComponent()
        myTypes.Add(GetType(ComboBox))
        myTypes.Add(GetType(CheckBox))
        myTypes.Add(GetType(RadioButton))
        myTypes.Add(GetType(TabControl))
        myTypes.Add(GetType(Button))
        myTypes.Add(GetType(Label))
        myTypes.Add(GetType(GroupBox))
        myTypes.Add(GetType(Window))
    End Sub
    
    Private Sub Window_MouseMove(sender As Object, e As MouseEventArgs)
        Dim x As DependencyObject = _
          DirectCast(e.MouseDevice.DirectlyOver, DependencyObject)
        Dim t As Type = x.GetType
        While Not myTypes.Contains(t)
             x = VisualTreeHelper.GetParent(x)
             If x Is Nothing Then Exit While
             t = x.GetType
        End While
    
        If x IsNot Nothing Then
              Console.WriteLine(x.ToString())
        Else
              Console.WriteLine("Nothing")
        End If
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have WPF Application where I have One main form and other user controls
I have wpf datagrid with number of template columns. some of them have textbox
I have a WPF Window which has a among other controls hosts a Frame.
I have a WPF TabControl which displays UserControl s. Some UserControl s are larger
I have WPF App, that needs to be update some data , after computer
Suppose you have WPF Window composed of many elements that are using DataTemplates /
I have wpf prism application with some modules. One module has folder sounds and
I have WPF application in which user enters some text in rich text box(rtb),
I have WPF window containing a listview that has it's itemsource set to a
I have a WPF application in VS 2008 with some web service references. For

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.