0

Is there any way to get the wpf/c# compiler to embed XAML straight into the assembly as normal XAML text, rather than compiling it to BAML? (this is to make it easier to look at and edit later on, once it's in the assembly)

thecoop
  • 45,220
  • 19
  • 132
  • 189
  • You would need to change the `build action` and `custom tool` of the file in the properties. How you would get this to run though i do not know. – H.B. Mar 14 '12 at 14:37
  • 1
    why don't you just use a BAML decompiler to view it as XAML? – Jake Berger Mar 14 '12 at 14:37
  • Why would it not run? Surely BAML is just compiled XAML, and the wpf subsystem can read straight XAML exactly the same way as BAML? – thecoop Mar 14 '12 at 14:38
  • @jberger: I want to edit it afterwards. XAML is much easier to understand and edit than BAML. – thecoop Mar 14 '12 at 14:39
  • @thecoop: If you can wire it up to find and load the file, sure. – H.B. Mar 14 '12 at 14:39
  • @H.B. But why would XAML embedded into the assembly in exactly the same was as BAML behave differently? – thecoop Mar 14 '12 at 14:41
  • @thecoop: Because `XAML != BAML` – H.B. Mar 14 '12 at 14:42
  • maybe try [this](http://stackoverflow.com/a/706955/503501) or [this](http://stackoverflow.com/a/1468524/503501) – Jake Berger Mar 14 '12 at 14:55
  • @H.B. what does BAML provide that XAML doesn't have? – thecoop Mar 14 '12 at 15:01
  • @thecoop: I do not know and it does not matter, usually compiled code is faster as it is optimized, in some cases uncompiled code will not run at all. If WPF can easily deal with embedded XAML then that is fine, but i doubt it as there is a lot of autogenerated code for windows and the like (`InitializeComponent`) and the tools which create that may not work with loose XAML. – H.B. Mar 14 '12 at 15:06

1 Answers1

0

I think you have to change compile settings to None and copy it to your output folder..

Then, when you're starting your application it must load the xaml dynamical at runtime (like CodeDOM if you compile code at runtime).

For this XamlReader looks nice, but never tried it.. Try this link: Loading XAML at runtime?

Community
  • 1
  • 1
Felix C
  • 1,755
  • 5
  • 26
  • 40