35

What is .baml file and what's the use of this file? Who creates this file?

akjoshi
  • 15,374
  • 13
  • 103
  • 121
Embedd_0913
  • 16,125
  • 37
  • 97
  • 135

4 Answers4

47

A compiled XAML file.

Wikipedia says:

A XAML file can be compiled into a .baml (Binary XAML) file, which may be inserted as a resource into a .NET Framework assembly. At run-time, the framework engine extracts the .baml file from assembly resources, parses it, and creates a corresponding WPF visual tree or workflow.

RuudKok
  • 5,252
  • 2
  • 26
  • 27
  • 11
    Key thing here is that it is essentially a compression technique - the XAML is still parsed and constructed by the runtime – Gordon Mackie JoanMiro Mar 13 '09 at 22:20
  • 1
    what are the advantages of compiling it into a baml and by that what are the advantages of using assembly resources instead of having keeping it as a file – eran otzap Feb 11 '14 at 13:33
  • 1
    @eranotzap performance. Catch more here: http://blogs.microsoft.co.il/tomershamam/2007/05/25/compiled-xaml-baml-not-il/ – nawfal Apr 28 '16 at 13:30
5

.baml = Binary Application Markup File, a compiled XAML file.

Patrick Peters
  • 9,456
  • 7
  • 57
  • 106
2

BAML form is an optimized form of XAML used by the WPF XAML implementation. It is optimized in the sense that it uses internal lookups and tokens for commonly used types or members. The optimization is useful as an implementation detail that addresses packaging size and load time for WPF application scenarios that involve XAML. Full Topic on Msdn

Greg Gum
  • 33,478
  • 39
  • 162
  • 233
-2

The purpose of BAML is only for checking if generated WPF controls have right values in their properties. Compiled XAML has also its auto-generated *.cs code. You can look at in your app\DEBUG\OBJ directory. Every XAML file has generated cs. Its name is XAMLfileName.g.cs where g means generated.

  • 1
    baml is a file format. It has nothing to do with whether or not the property values are correct. They are not checked until the xaml reader attempts to create the object tree. – Greg Gum Jul 27 '13 at 16:15