XAML project file is compiled into a binary representation of the XAML code - Binary Application Markup Language (BAML). Then the BAML code is embedded as a resource in the final assembly of the application - exe or dll file. It concerns XAML. However, what about the graphical elements created in C# Code (! ) while the application is running?
Let's say the application is an empty window:
<Window x:Class="WpfApp.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<StackPanel x:Name="WindowStackPanel">
<Button Click="CreateButtonEvent" Content="I was created at compile time" />
</StackPanel>
</Window>
This XAML is compiled into an executable resource.
On mouse event, I add new button(s) - is a graphical element(s) and it was not compiled into BAML during the build of the application:
private void CreateButtonEvent(object sender, RoutedEventArgs e)
{
WindowStackPanel.Children.Add(new Button() { Content = "Where was I created?" });
}
In this regard, the question is: what technically happens when I create a graphic item (button) in C# Code (not XAML code) while the application is running? Is it writing to the shared resource created by BAML, or is it creating its own temporary resource that JIT is already reading? Thanks