Reputation: 4502
I'm creating a generator for UserControls in C#. It looks nearly like this:
UserControl control = new UserControl();
Grid contentGrid = new Grid();
control.Content = contentGrid;
//create Buttons, Labels, Bindings etc.
return control;
now my Question is whether I can get the XAML of the created UserControl at runtime, and if it is possible, how I can do that.
For instance from the Code above I want to retrieve Something like:
<UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid>
....
</Grid>
</UserControl>
Upvotes: 2
Views: 239