//my adorner OnRender method:
protected override void OnRender(DrawingContext drawingContext)
{
Button foo = new Button();
foo.Content = "bla";
DrawingGroup drawingGroup = VisualTreeHelper.GetDrawing(foo);
if (drawingGroup != null)
{
Debug.WriteLine("got group!");
// Enumerate the drawings in the drawing group.
for (int i = 0; i < drawingGroup.Children.Count; i++)
{
drawingContext.DrawDrawing(drawingGroup.Children
}
}
}
Can anybody help me out on this one Am I missing something

How can I get the Drawing of a Button for rendering on an Adorner?
elixic
Thanks for your fast reply! Will check tomorrow if your tip suits my needs!
Basically I want to replicate the behaviour of the WPF Validation where the content of the Validation.ErrorTemplate control template gets rendered to an adorner that is shown at any control for error information. Unfortunately we can't use the WPF Validation in our programs as we do validations in our business logic to be more UI independent so I need to replicate the error indication behaviour by myself but until now i have no clue (as you saw with my trys) how to do this.
Maybe you know the magic behind the Validation error indication stuff using adorners in WPF
guyinkalamazoo2
Covi
Charlotte Adam
Well, his article (which i had known) has not the solution for my problem as it uses the Validation Class of WPF but I can't use this class for reasons described above, so I need to plumb the Adorner stuff in a similar manner by myself but i don't know how it is done.
aliasx
Blake01
I believe this doesn't work because Button uses styling to be rendered and doesn't have its own OnRender method. Note that in general getting the drawing data from a visual is going to be a fragile affair because you won't get the drawings of any of the visual's children. Many classes that are exposed as a single control are in fact the amalgomation of a number of child visuals.
Instead of trying to get the drawing out of a Button, can you instead use a VisualBrush
JUANCARLOSR
I know the content of the article very well since I use the system described in it with validation in the business layer, but Paul does NOT describe how to render error messages to an adorner in a way the WPF Validation class does.
EDIT: I think i got the solution, will post later if it works :)
SOLUTION FOUND, thanks to the snoop program by pete blois.