WPF: can a UserControl be saved as xaml or baml at runn-time?

  • Thread starter Thread starter Haiping
  • Start date Start date
H

Haiping

I have a UserControl whith Canvas as its content. It lets uses add controls,
include Labels, TextBox, Charts, into this UserControl. After user is done
with it can it be saved as XAML or BAML file? So later user can load his
file, and edit it. If the UserControl cannot be saved as XAML or BAML what
is the other way to save it ?

thanks for any inputs,
 
I have a UserControl whith Canvas as its content. It lets uses add controls,
include Labels, TextBox, Charts, into this UserControl. After user is done
with it can it be saved as XAML or BAML file?

Have a look at XamlWriter.Save. This comes with some limitations,
though - for example, it will resolve and expand StaticResource
references in the output, and it will ignore event handlers.
 
I have a UserControl whith Canvas as its content. It lets uses add controls,
include Labels, TextBox, Charts, into this UserControl. After user is done
with it can it be saved as XAML or BAML file?

Have a look at XamlWriter.Save. This comes with some limitations,
though - for example, it will resolve and expand StaticResource
references in the output, and it will ignore event handlers.
 
Thank you Pavel,
I found XamlWriter.Save too. I may not need event handler in my UserControl.
I am going to try it.
 
Thank you Pavel,
I found XamlWriter.Save too. I may not need event handler in my UserControl.
I am going to try it.
 
Back
Top