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.Generatornuget package:dotnet add package ShowMeTheXaml.Avalonia.Generator
This will also install the
ShowMeTheXaml.Avalonianuget 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
DisplayContentdictionary inXamlDisplayclass:
AddUseXamlDisplay()inProgram.cstoBuildAvaloniaAppmethod. 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
XamlDisplayin your xaml. Set uniqueUniqueIdproperty 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.Avaloniause (install)ShowMeTheXaml.Avalonia.AvaloniaEditnuget 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