Glossary · WPF

What is BAML?

BAML (Binary Application Markup Language) is the compiled, binary form of a WPF XAML file. When you build a WPF application, each window, page, and resource dictionary written in XAML is compiled to a .baml stream and stored in the assembly, where WPF loads it at runtime instead of parsing XAML.

Made by
The WPF build, from each .xaml
Stored in
MyApp.g.resources inside the assembly
Holds
The element tree, properties, and UI text
Localized in
Satellite assemblies, one per culture

Where BAML lives in your build.

The build compiles MainWindow.xaml to mainwindow.baml and embeds it in a resource named MyApp.g.resources. Your C# or VB code loads it through InitializeComponent.

MyApp.exe
└─ MyApp.g.resources
   ├─ mainwindow.baml        ← compiled MainWindow.xaml
   ├─ settingsdialog.baml
   └─ themes/generic.baml
de\MyApp.resources.dll       ← German satellite: translated BAML

Because the text of the user interface is inside BAML, a compiled WPF application can be translated without its XAML sources: the translated BAML goes into a satellite assembly in a culture folder, and WPF picks it by the user's UI culture.

BAML and XAML.

XAML compared with BAML
XAMLBAML
FormXML text you writeBinary, made by the build
WhereIn the projectIn the assembly's resources
Read at runtimeNo (except loose XAML)Yes, faster than parsing XML
Edited byVisual Studio, BlendNot by hand

BAML to XAML. To read a compiled window as XAML, open the assembly in a .NET decompiler such as ILSpy: it shows the BAML resources as XAML. For translation you do not need that step: a localization tool reads the BAML directly.

How BAML is localized.

Each element with text needs a stable x:Uid, added with msbuild /t:updateuid, so a translation finds its element again in the next build. Then:

  1. Read the BAMLfrom the compiled EXE and DLL files, keyed by x:Uid.

  2. Translatethe text of each element, with the window in view.

  3. Write satelliteswith the translated BAML: de\MyApp.resources.dll, fr\MyApp.resources.dll.

Microsoft's LocBaml sample does these steps with CSV files on .NET Framework. Lingobit Localizer does them on .NET Framework 4.8 and .NET 5–10, with a visual preview of each window, validation, and Scan for Changes for the next build, in every edition.

Questions.

What does BAML stand for?

Binary Application Markup Language: the binary form of XAML (Extensible Application Markup Language) that WPF compiles into the assembly.

Can I edit a BAML file directly?

Not by hand: change the XAML and build again. Localization tools change BAML in their own output, the satellite assemblies, and leave your build as it is.

Is BAML used outside WPF?

BAML is WPF's format. WinForms keeps its UI text in .resx resources, and UWP and WinUI compile XAML to .xbf and keep their text in .resw files.