BAML->XAML

Hi all!

I know you don't like people using BAML, but I've got a bit of a problem: I have a program that I've written, and have lost the source code for. Luckily, I have the compiled executable. So, I have been able to extract the BAML file, but I'd really like it in XAML for easy editing. I know about loading BAML with Application.LoadCompenent, but that doesn't help when you need to 'decompile' BAML in to XAML.

I've been told this was possible in earlier versions of WPF, but has been removed ever since Parser.LoadBaml was removed. Is there any way to retrieve the XAML source?

Karl

[621 byte] By [Blackice] at [2007-12-23]
# 1
After you have done Application.LoadCompenent to retrive an object instance from BAML, you should be able to use XamlWriter.Save, to save that object to Xaml. This won't give you the complete sourcecode, but it should give you a start.
Sam at 2007-8-30 > top of Msdn Tech,Visual Studio Orcas,Windows Presentation Foundation (WPF)...
# 2

Thanks!

Now my problem is Uris. I'm having great trouble getting relative Uris to all the loose baml files I have. How would I get a relative Uri to a file like "C:\foo.baml"? I've tried:

Uri uri = new Uri("C:\\foo.baml");
uri.MakeRelative(Application.Current.StartupUri);

object baml = Application.LoadComponent(uri);

But that doesn't work.

Blackice at 2007-8-30 > top of Msdn Tech,Visual Studio Orcas,Windows Presentation Foundation (WPF)...

Visual Studio Orcas

Site Classified