07-01-2010, 03:02 PM
You can use System.Windows.Markup.XamlWriter class (http://msdn.microsoft.com/en-us/library/...riter.aspx).
But the created xaml will not be formatted and you will not be able to export embedded images. In some cases it can also create xaml that is not correct (will produce compiler errors). But you can give it a try.
This class is also used in Paste2Xaml (and ViewerSvg) when you uncheck the "Use Advanced XamlWriter" checkbox in Export dialog.
I am planning to create a separate library that would also have GetXaml method that could create formated xaml from any WPF object (and not only from read objects). The library would also have some other useful WPF 2D tools. But I cannot say when it will be available.
But the created xaml will not be formatted and you will not be able to export embedded images. In some cases it can also create xaml that is not correct (will produce compiler errors). But you can give it a try.
This class is also used in Paste2Xaml (and ViewerSvg) when you uncheck the "Use Advanced XamlWriter" checkbox in Export dialog.
I am planning to create a separate library that would also have GetXaml method that could create formated xaml from any WPF object (and not only from read objects). The library would also have some other useful WPF 2D tools. But I cannot say when it will be available.

