优化更新代码,添加界面功能并整合
This commit is contained in:
39
WPFluent/Markup/ThemeResourceExtension.cs
Normal file
39
WPFluent/Markup/ThemeResourceExtension.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
|
||||
|
||||
|
||||
using System.Windows.Markup;
|
||||
|
||||
namespace WPFluent.Markup;
|
||||
|
||||
/// <summary>
|
||||
/// Class for Xaml markup extension for static resource references.
|
||||
/// </summary>
|
||||
/// <example>
|
||||
/// <code lang="xml"> /// <ui:Button /// Appearance="Primary" /// Content="WPF UI button with font icon" ///
|
||||
/// Foreground={ui:ThemeResource SystemAccentColorPrimaryBrush} /> ///</code> <code lang="xml"> /// <ui:TextBox
|
||||
/// Foreground={ui:ThemeResource TextFillColorSecondaryBrush} /> ///</code>
|
||||
/// </example>
|
||||
[TypeConverter(typeof(DynamicResourceExtensionConverter))]
|
||||
[ContentProperty(nameof(ResourceKey))]
|
||||
[MarkupExtensionReturnType(typeof(object))]
|
||||
public class ThemeResourceExtension : DynamicResourceExtension
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ThemeResourceExtension"/> class.
|
||||
/// </summary>
|
||||
public ThemeResourceExtension() { ResourceKey = ThemeResource.ApplicationBackgroundBrush.ToString(); }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ThemeResourceExtension"/> class. Takes the resource key that this
|
||||
/// is a static reference to.
|
||||
/// </summary>
|
||||
public ThemeResourceExtension(ThemeResource resourceKey)
|
||||
{
|
||||
if(resourceKey == ThemeResource.Unknown)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(resourceKey));
|
||||
}
|
||||
|
||||
ResourceKey = resourceKey.ToString();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user