Search code examples
c#wpfxamlavaloniaui

Is it possible to load XAML runtime in Avalonia


In WPF it is possible to load XAML at runtime and put it in a ContentControl using XamlReader.Load()

Is this possible in Avalonia?

I want to get to a point where I have a user control that contains a content control and based on my configuration, this could point to a file on disk having XAML code to read.

In WPF this works nicely, and the XAML is imported, parsed and the datacontext is inherited, allowing my to put data inside the loaded XAML through my databindings.

I have been searching for an equivalent in Avalonia, but not been successfull.


Solution

  • Install Avalonia.Markup.Xaml.Loader package and use AvaloniaRuntimeXamlLoader class.