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

  • Home
  • SEARCH
  • 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 865919
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T09:42:58+00:00 2026-05-15T09:42:58+00:00

I know that it is possible to parse an XAML – file at runtime

  • 0

I know that it is possible to parse an XAML – file at runtime and create an UIElement which I can insert into my pages grid, no problem there.

But what I really want is to replace the whole XAML of my page or usercontrol, is that possible, too?

Reasoning:

I want to give the users of my application the opportunity to have the application run (startup takes ages – and that can’t be shortened because of some legacy issues) and simply update the view by “ctrl + s” in Blend.

  • 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-15T09:42:59+00:00Added an answer on May 15, 2026 at 9:42 am

    It depends on whether you attach event handlers or use the “Name” or “x:Name” attribute to access UI elements from code.

    Nice pure MVVM application

    First let’s assume you have a nice pure MVVM application that uses binding and commands exclusively, so you aren’t using named UI elements or code-behind event handlers. Good for you: You have a nice clean application architecture and I like you.

    In that case all you need to do is create a temporary copy of your XAML file with the x:Class attribute removed, and call:

     Application.LoadComponent(this, uriToTemporaryCopy);
    

    Ugly impure non-MVVM application

    Now let’s assume you used an element named with x:Name or Name from your code-behind (naughty, naughty, naughty!), or you attached an event handler using XAML (less naughty but not pure either). You don’t have a nice clean architecture, but I still like you anyway.

    In this case, Application.LoadComponent won’t do the trick by itself because these settings require integration with the code-behind. You also need to find a way to invoke the BAML compiler.

    Since the code-behind integration is already compiled into your Page or UserControl subclass, there are some restrictions:

    1. You cannot add, remove, or change the sequence of event handler assignments
    2. You cannot change the names or sequences of named elements or add more named elements

    If you abide by these rules, in general the generated code that is incorporated into your class will not change, therefore you can load the new XAML file into a running application without breaking anything.

    The procedure is:

    1. Compile the XAML file to BAML either by A) building the containing project, B) creating a temporary project and compiling that, or C) directly calling the markup compiler tasks in PresentationBuildTasks.
    2. Use Application.LoadComponent to load the BAML file just as you did for the edited XAML file in the pure solution.

    In a compiled .csproj project, any compiled BAML files will be found under the obj/debug or obj/release directory with an extension of .baml. If you call the markup compiler task directly you can decide on the output location.

    What is a BAML file?

    For those who don’t know, BAML is basically a compressed and optimized binary form of XAML, and is the way your XAML is stored inside your .exe or .dll. It also has capabilities for linking directly to generated code, which XAML does not have.

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

Sidebar

Ask A Question

Stats

  • Questions 460k
  • Answers 460k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Here is my solution. I've tested it with some Excel… May 15, 2026 at 11:45 pm
  • Editorial Team
    Editorial Team added an answer Put the fetch in a logrotate postrotate script, and fetch… May 15, 2026 at 11:45 pm
  • Editorial Team
    Editorial Team added an answer propably the highcharts library. JavaScript on the iPhone is not… May 15, 2026 at 11:45 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.