1

Like Visual studio or any other IDE, Dynamically created controls in a tab page has to be saved and retrieved back is the task. I have tried the methodology of converting mycontrolsclass which has dynamically created controls in a list into json which will be saved to database and retrieved back. The stackoverflow error happens when the entire mycontrolsclass has been serialised to json. So thought of having a xaml content to database. Several tutorials helps out to get xaml content of a wpf window physical file but not aware of getting a xamlcontent out of a window which has dynamically created controls.

Tried looping through LogicalTreeHelper class too but i couldnt get the exact xaml. Is my methodology correct or how can i get xaml for dynamically created controls?

timblistic
  • 553
  • 2
  • 10
  • 26
  • 1
    [Here](http://stackoverflow.com/q/15003183/1997232) is something similar. You can also search separately for "xaml load runtime" and "xaml save runtime" (should lead you to related questions). – Sinatr Apr 18 '16 at 14:20

1 Answers1

2

I guess XamlWriter.Save() is that what you're looking for.

Eldar Dordzhiev
  • 5,105
  • 2
  • 22
  • 26
  • Great help, but xaml serialize error happens as follows which i couldnt overcome. an unhandled exception of type 'System.InvalidOperationException' occurred in PresentationFramework.dll Additional information: Cannot serialize a non-public type 'FormsSuite.CustomControl.CustomTabItem'. – timblistic Apr 19 '16 at 11:56
  • 1
    @ArulManivannan Just make `FormsSuite.CustomControl.CustomTabItem` public, that should work. – Eldar Dordzhiev Apr 19 '16 at 16:04
  • Worked like a charm, was hesitant to put that error in the previous comment. Now your comment too has helped me to save some days. Thanks. – timblistic Apr 20 '16 at 11:36