Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 354611
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T11:56:26+00:00 2026-05-12T11:56:26+00:00

As far as I know, everything done in XAML can be done in C#.

  • 0

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 at compile-time and create the corresponding C# code ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T11:56:26+00:00Added an answer on May 12, 2026 at 11:56 am

    This blog post should provide a comprehensive answer: http://blogs.microsoft.co.il/blogs/tomershamam/archive/2007/05/25/Compiled-XAML-3D00-BAML-not-IL.aspx

    Yesterday I lectured about XAML and the following question was asked: Why XAML is compiled into BAML and not directly into IL for better performance?

    Before giving the correct answer, I want to explain what BAML is.

    There are actually two ways for handling a XAML file: Loose or Compiled.

    1. Loose XAML file should be parsed at runtime, and can be deployed as a simple XML file, locally, remotely or embedded into the assembly.
    2. Compiled is a XAML file marked as “Page” in Visual Studio ( in MSBuild), deployed as a BAML (Binary Application Markup Language) file and embedded as an assembly resource.

    A loose XAML file can’t include the x:Class XAML keyword, also it can’t embed a source code, nor it can emit code by all means. It is possible to load a loose XAML file by calling XamlReader.Load() method, casting the return value into the root element. The loose XAML version provides a dynamic way to load and change the view, but provides poor performance due to the fact that the XML file is parsed at runtime.

    A compiled XAML file (BAML) can emit code, by using x:Class, or by registering events for example. It is possible to load an element from inside the BAML by calling the Application.LoadComponent(), casting the return value into the root element. The compiled XAML version provides better performance since it is pre-tokenized binary version of the XAML file, hence it is smaller and can be loaded faster, but it is not dynamic.

    Once upon a time, there was CAML. CAML was the exact IL version of the compiled XAML file. Unfortunately, the WPF team has decided to eliminate it, and keep the BAML version for the following reasons:

    1. BAML is compact hence it can be downloaded faster (good for XBAP applications)
    2. BAML is less security threat than code execution (good for XBAP applications)
    3. BAML can be localized after compilation

    In the bottom line, BAML is a little slower than IL but has more advantages than CAML.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.