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?

1
  • 1
    Here is something similar. You can also search separately for "xaml load runtime" and "xaml save runtime" (should lead you to related questions). Commented Apr 18, 2016 at 14:20

1 Answer 1

2

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

Sign up to request clarification or add additional context in comments.

3 Comments

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'.
@ArulManivannan Just make FormsSuite.CustomControl.CustomTabItem public, that should work.
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.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.