Skip to content

A WPF component making it easy to show the corresponding XAML for WPF custom styles and controls

License

Notifications You must be signed in to change notification settings

unoplatform/ShowMeTheXAML

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

126 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

ShowMeTheXAML

A WPF component making it easy to show the corresponding XAML for WPF custom styles and controls. It was built out of a need to shows the XAML for the theme library MaterialDesignInXamlToolkit. You can see it working in the demo application for MaterialDesignInXamlToolkit.

NuGet Status NuGet Status NuGet Status

AppVeyor

Setup

  1. Install the MSBuild package. PM> Install-Package ShowMeTheXAML.MSBuild This will also install the ShowMeTheXAML package as well.
  2. Add the following code in your App.xaml.cs
protected override void OnStartup(StartupEventArgs e)
{
    XamlDisplay.Init(
        // optional list of assemblies to look for ShowMeTheXAML data from.
        // Automatically tries to load data from Assembly.GetEntryAssembly()
    );
    base.OnStartup(e);
}

XamlDisplay.Init() does not work under Native AOT. For Native AOT support, invoke XamlDictionary.Init() from your App.xaml.cs:

protected override void OnStartup(StartupEventArgs e)
{
    XamlDictionary.Init();
    base.OnStartup(e);
}

Note: the difference between XamlDisplay.Init() and XamlDictionary.Init() is that XamlDictionary.Init() will look for XamlDictionary from Assembly.GetEntryAssembly() and from the list of Assembly instances provided to XamlDisplay.Init(). XamlDictionary.Init() does not. As such, if multiple assemblies contain XamlDictionary types, new public APIs will need to be added to each such assembly and explicitly invoked in order for the XamlDictionary data to be used.

  1. (Optional) The default template is pretty basic. For a better looking style add the ShowMeTheXAML.AvalonEdit package. PM> Install-Package ShowMeTheXAML.AvalonEdit In App.xaml include the resource dictionary.
<Application.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="pack://application:,,,/ShowMeTheXAML.AvalonEdit;component/Themes/xamldisplayer.xaml" />
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
</Application.Resources>

Usage

<smtx:XamlDisplay Key="SomeUniqueString">
  <StackPanel>
    <Button Content="Some Content" />
    <TextBlock Text="Text" />
  </StackPanel>
</smtx:XamlDisplay>

About

A WPF component making it easy to show the corresponding XAML for WPF custom styles and controls

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

  • C# 84.9%
  • PowerShell 15.1%