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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T10:50:08+00:00 2026-05-24T10:50:08+00:00

I have an adorner defined as follows: private class ErrorAdorner : Adorner { private

  • 0

I have an adorner defined as follows:

    private class ErrorAdorner : Adorner
    {
        private readonly Border _errorBorder;

        public ErrorAdorner(UIElement adornedElement)
            : base(adornedElement)
        {
            _errorBorder = new Border();
            _errorBorder.BorderThickness = new Thickness(2);
            _errorBorder.BorderBrush = Brushes.Red;
            Image img = new Image();
            img.HorizontalAlignment = HorizontalAlignment.Right;
            img.VerticalAlignment = VerticalAlignment.Center;
            img.Stretch = Stretch.None;
            Binding imgBinding = new Binding
            {
                Source = adornedElement,
                Path = new PropertyPath(IconProperty)
            };
            img.SetBinding(Image.SourceProperty, imgBinding);
            Binding ttBinding = new Binding
            {
                Source = adornedElement,
                Path = new PropertyPath(ErrorMessageProperty)
            };
            img.SetBinding(ToolTipProperty, ttBinding);
            _errorBorder.Child = img;
        }

        protected override Size MeasureOverride(Size constraint)
        {
            AdornedElement.Measure(constraint);
            return AdornedElement.RenderSize;
        }

        protected override Size ArrangeOverride(Size finalSize)
        {
            _errorBorder.Arrange(new Rect(finalSize));
            return finalSize;
        }

        protected override Visual GetVisualChild(int index)
        {
            if (index == 0)
                return _errorBorder;
            throw new ArgumentOutOfRangeException("index");
        }

        protected override int VisualChildrenCount
        {
            get
            {
                return 1;
            }
        }
    }

ErrorMessage and Icon are attached properties declared in an enclosing class (ErrorProvider). The adorner is added to an element when the ErrorMessage property is set to a non-null value.

My problem is that while the adorner is properly rendered, the ToolTip on the image doesn’t show up when I move the mouse over it. I know it isn’t a binding issue: when I examine the controls with Snoop, I can see that the ToolTip property has the expected value. I suspect the problem is related to hit testing, because I can’t receive any mouse related event in the adorner… The IsHitTestVisible property is set to true, so I don’t understand why I don’t receive the events.

Any idea?

  • 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-24T10:50:08+00:00Added an answer on May 24, 2026 at 10:50 am

    Ok, this is something that has bitten me before also. When you define your own visual tree, it isn’t enough to just return the visual children, you also need to tell WPF that you’ve added them. At the end of your constructor just add this:

    this.AddVisualChild(_errorBorder);
    this.AddLogicalChild(_errorBorder);
    

    You should also implement the LogicalChildren property:

    protected override System.Collections.IEnumerator LogicalChildren
    {
        get 
        { 
            yield return _errorBorder;
        }
    }
    

    If you had multiple children, I’d use the UIElementCollection. It will add them to the visual and logical trees, and you can just use it from the LogicalChildren, VisualChildrenCount, and GetVisualChild overrides.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a dependency property on a class inheriting from adorner, like so: public
I have an Adorner which adornes a Border (please see screenshot below). The MouseDown
I have a custom control (an Adorner) that wraps another control (a textbox). public
have written this little class, which generates a UUID every time an object of
I have an expander defined as such; <Canvas Panel.ZIndex=99> <Expander HorizontalAlignment=Left VerticalAlignment=Top> <StackPanel Background=White>
I have an Adorner and I want that Adorner to be able to receive
I have an Adorner in XAML that I'm using for ErrorValidation. Basically I have
I have a control template defined, call it myVal, that is used for validation
I have a problem with my adorner which is supposed to preview the destination
I have a richTextBox Editor that contains image adorner layers on top of each

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.