using System.Windows.Markup; namespace WPFluent.Markup; /// /// Class for Xaml markup extension for static resource references. /// /// /// /// <ui:Button /// Appearance="Primary" /// Content="WPF UI button with font icon" /// /// Foreground={ui:ThemeResource SystemAccentColorPrimaryBrush} /> /// /// <ui:TextBox /// Foreground={ui:ThemeResource TextFillColorSecondaryBrush} /> /// /// [TypeConverter(typeof(DynamicResourceExtensionConverter))] [ContentProperty(nameof(ResourceKey))] [MarkupExtensionReturnType(typeof(object))] public class ThemeResourceExtension : DynamicResourceExtension { /// /// Initializes a new instance of the class. /// public ThemeResourceExtension() { ResourceKey = ThemeResource.ApplicationBackgroundBrush.ToString(); } /// /// Initializes a new instance of the class. Takes the resource key that this /// is a static reference to. /// public ThemeResourceExtension(ThemeResource resourceKey) { if(resourceKey == ThemeResource.Unknown) { throw new ArgumentNullException(nameof(resourceKey)); } ResourceKey = resourceKey.ToString(); } }