As far as I know, everything done in XAML can be done in C#.
Why XAML is compiled in BAML and not in C# ? Wouldn't be more efficient to parse the XAML a compile-time and create the corresponding C# code ?
As far as I know, everything done in XAML can be done in C#.
Why XAML is compiled in BAML and not in C# ? Wouldn't be more efficient to parse the XAML a compile-time and create the corresponding C# code ?
The Xaml is separate from the c# code because it allows these elements to be "soft-coded." If you compile the Xaml to C# code, you defeat this characteristic, because now the UI elements, data binding, eventing, etc. are now hard-coded into the program, and you need to recompile the entire program to make a minor change to the user interface.
The blog post that petr k. references says that Xaml actually was compiled to IL at one time, but Baml is now used because:
This blog post should provide a comprehensive answer: http://blogs.microsoft.co.il/blogs/tomershamam/archive/2007/05/25/Compiled-XAML-%5F3D00%5F-BAML-not-IL.aspx