Turns out, after a little more exploration, that the Template property will be null unless the control has been rendered on the screen.
Bob Bedell
Posts
-
default control template xaml -
default control template xamlIt appears that when you construct a WPF control in code, its Template property isn't initialized. For example: ListBox listBox = new ListBox(); If you instantiate a ListBox like this, then walk the object hierarchy down to the Template property of the Control base class, you'll see that it hasn't been initilaized.
-
default control template xamlThe error is obviously thrown by the line: XamlWriter.Save(template, writer); since template is null.
-
default control template xamlI ran your first version which looks promising, only the line: ControlTemplate template = control.Template; Always assigns a null value to the template variable. The error message is typically: << Error generating template: Parameter name: obj>> Are you seeing the same thing? Thanks for your reply, Bob
-
default control template xamlDoes anyone know where to find the complete default control template xaml listings for the WPF controls? Thanks. Bob