41 lines
1.2 KiB
C#
41 lines
1.2 KiB
C#
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
using System.Windows.Markup;
|
|||
|
|
|
|||
|
|
// ReSharper disable once CheckNamespace
|
|||
|
|
namespace WPFluent.Controls;
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// Represents an icon that uses an IconSource as its content.
|
|||
|
|
/// </summary>
|
|||
|
|
[ContentProperty(nameof(IconSource))]
|
|||
|
|
public class IconSourceElement : IconElement
|
|||
|
|
{
|
|||
|
|
/// <summary>
|
|||
|
|
/// Identifies the <see cref="IconSource"/> dependency property.
|
|||
|
|
/// </summary>
|
|||
|
|
public static readonly DependencyProperty IconSourceProperty = DependencyProperty.Register(
|
|||
|
|
nameof(IconSource),
|
|||
|
|
typeof(Controls.IconSource),
|
|||
|
|
typeof(IconSourceElement),
|
|||
|
|
new FrameworkPropertyMetadata(null));
|
|||
|
|
|
|||
|
|
protected override UIElement InitializeChildren()
|
|||
|
|
{
|
|||
|
|
// TODO: Come up with an elegant solution
|
|||
|
|
throw new InvalidOperationException($"Use {nameof(CreateIconElement)}");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public IconElement? CreateIconElement() { return IconSource?.CreateIconElement(); }
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// Gets or sets <see cref="IconSource"/>
|
|||
|
|
/// </summary>
|
|||
|
|
public Controls.IconSource? IconSource
|
|||
|
|
{
|
|||
|
|
get => (Controls.IconSource?)GetValue(IconSourceProperty);
|
|||
|
|
set => SetValue(IconSourceProperty, value);
|
|||
|
|
}
|
|||
|
|
}
|