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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T14:43:22+00:00 2026-05-27T14:43:22+00:00

Using the DrawingContext class I’ve been able to use the DrawRectangle() method to successfully

  • 0

Using the DrawingContext class I’ve been able to use the DrawRectangle() method to successfully add an adorner to my adornedElement.

Is it possible to construct a stackpanel, with a textbox and image inside – and assign this as the adorner?

I’m using visual studio 2010 by the way – not microsoft expression.

Thanks a lot,

Dan

  • 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-27T14:43:23+00:00Added an answer on May 27, 2026 at 2:43 pm

    No, this is not possible out of the box as the DrawingContext is only meant to draw Visuals and no FrameworkElements.
    What you can do is create your own Adorner which is able to draw FrameworkElements:

      public class FrameworkElementAdorner : Adorner
      {
        private FrameworkElement _child;
    
        public FrameworkElementAdorner(UIElement adornedElement)
          : base(adornedElement)
        {
        }
    
        protected override int VisualChildrenCount
        {
          get { return 1; }
        }
    
        public FrameworkElement Child
        {
          get { return _child; }
          set
          {
            if (_child != null)
            {
              RemoveVisualChild(_child);
            }
            _child = value;
            if (_child != null)
            {
              AddVisualChild(_child);
            }
          }
        }
    
        protected override Visual GetVisualChild(int index)
        {
          if (index != 0) throw new ArgumentOutOfRangeException();
          return _child;
        }
    
        protected override Size MeasureOverride(Size constraint)
        {
          _child.Measure(constraint);
          return _child.DesiredSize;
        }
    
        protected override Size ArrangeOverride(Size finalSize)
        {
          _child.Arrange(new Rect(new Point(0, 0), finalSize));
          return new Size(_child.ActualWidth, _child.ActualHeight);
        }
      }
    

    Usage:

      var fweAdorner = new FrameworkElementAdorner(adornedElement);
    
      //Create your own Content, here: a StackPanel with some stuff inside
      var stackPanel = new StackPanel();
      stackPanel.Children.Add(new TextBox() { Text="TEST"});
      stackPanel.Children.Add(new Image());
    
      fweAdorner.Child = stackPanel;
    
      var adornerLayer = AdornerLayer.GetAdornerLayer(adornedElement);
      adornerLayer.Add(fweAdorner);
    

    You could also incorporate the creation of the StackPanel directly in the Adorner if you use this combination of a StackPanel multiple times. That depends on your scenario.

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

Sidebar

Related Questions

I'm using an Adorner in .NET 3.5, and I'm able to draw by overriding
When using DrawingContext . DrawRectangle with a TileBrush , I noticed that the top-left
I have a Canvas with a scale translation applied in XAML. Using DrawingContext I
Using PyObjC , you can use Python to write Cocoa applications for OS X.
Using C#, I need a class called User that has a username, password, active
I'm using AvalonEdit, and I want the user to always be able to see
I have a UIView class that I am using to have a CALayer. This
I am doing some custom drawing using DrawingContext in WPF. I am using DrawingContext.DrawText
I was tying to add WPF code-behind embedded in the XAML and compile using
Using CoreGraphics (inside my drawRect method), I'm trying to apply a blend mode to

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.