I have made a custom control for windows phone 7.
If I use this control in XAML code, it shows up in both the designer and the emulator.
But if I create in C# code and render it in a WriteableBitmap, nothing shows up in the WriteableBitmap, and the OnApp开发者_如何学GolyTemplate does not get called either.
I tried calling the ApplyTemplate method and the Measure and Arrange methods, but none of them can make the control to be rendered.
So what is the right approach to make a custom control renderable in a WriteableBitmap?
Thanks.
Before a WPF template is applied, which includes Silverlight, an object must be added to a visual tree. Calling ApplyTemplate will simply fail if the object isn't in a visual tree. So to make it render properly, add it to a visual tree, then you can call ApplyTemplate / UpdateLayout / etc. and have it render correctly.
精彩评论