An Avalonia component making it easy to show the corresponding XAML for custom styles and controls. It was built out of a need to shows the XAML for the theme library Material.Avalonia.
-
Install
ShowMeTheXaml.Avalonia.Generator
nuget package:dotnet add package ShowMeTheXaml.Avalonia.Generator
This will also install the
ShowMeTheXaml.Avalonia
nuget package as well. -
Add XamlDisplay style to your app in
App.xaml
. See the example ofApp.xaml
:<Application ...> ... <Application.Styles> ... <!-- This line \/ required --> <StyleInclude Source="avares://ShowMeTheXaml.Avalonia/XamlDisplay.xaml"/> <!-- This line /\ required --> </Application.Styles> ... </Application>
-
Initialize
DisplayContent
dictionary inXamlDisplay
class:
AddUseXamlDisplay()
inProgram.cs
toBuildAvaloniaApp
method. It should look like this:public static AppBuilder BuildAvaloniaApp() => AppBuilder.Configure<App>() .UsePlatformDetect() .LogToTrace() // This line \/ .UseXamlDisplay() // This line /\ .UseReactiveUI();
Or call
XamlDisplayInternalData.RegisterXamlDisplayData()
on your program startup. -
Add
XamlDisplay
in your xaml. Set uniqueUniqueId
property value. Example:<showMeTheXaml:XamlDisplay UniqueId="123"> <!-- Your code here --> </showMeTheXaml:XamlDisplay>
Style for displaying xaml content inside AvaloniaEdit (AvalonEdit)
Refer to usual getting started but:
- Instead
ShowMeTheXaml.Avalonia
use (install)ShowMeTheXaml.Avalonia.AvaloniaEdit
nuget packagedotnet add package ShowMeTheXaml.Avalonia.AvaloniaEdit
- Use another style. Instead
use
<StyleInclude Source="avares://ShowMeTheXaml.Avalonia/XamlDisplay.xaml"/>
<StyleInclude Source="avares://ShowMeTheXaml.Avalonia.AvaloniaEdit/XamlDisplayStyles.axaml"/>
Everything else remains the same.
-
Clone this repo:
git clone https://github.com/AvaloniaUtils/ShowMeTheXaml.Avalonia.git
-
Navigate to repo folder
-
Fetch all submodules:
git submodule update --init --recursive
-
Compile project:
dotnet build