tags:

views:

53

answers:

1

I have a custom control

public partial class MyUserControl : UserControl { ... }

I get 'null' calling

VisualTreeHelper.GetDrawing(this)

How can I change MyUserControl to return non-null value? Any overloads, or what?

This is not a practical task, just a research.

+2  A: 

Although the documentation doesn't say anything about this, it seems that only returns a drawing for visuals that implement OnRender functionality. I tested it out on a shape, and also on a Window that overrode OnRender, and both returned the drawing.

However, if the Window doesn't override OnRender, the method returns null. I also made the call after the controls had been loaded, in case you were not doing that.

Abe Heidebrecht