mirror of
https://github.com/holgerb83/ModernWpfPlayground.git
synced 2025-06-30 09:40:52 +02:00
Reorganization of files
This commit is contained in:
43
Controls/PropertyPresenter/MagicSymbolControl.cs
Normal file
43
Controls/PropertyPresenter/MagicSymbolControl.cs
Normal file
@ -0,0 +1,43 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Markup;
|
||||
|
||||
namespace Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for <see cref="MagicSymbolControl"/>
|
||||
/// </summary>
|
||||
[ContentProperty(nameof(Symbol))]
|
||||
public class MagicSymbolControl : ContentControl
|
||||
{
|
||||
/// <summary>
|
||||
/// Dependency property for <see cref="Symbol"/> property
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty SymbolProperty = DependencyProperty.Register(nameof(Symbol), typeof(object), typeof(MagicSymbolControl), new PropertyMetadata(default, PropertyChangedCallback));
|
||||
|
||||
private static void PropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (d is MagicSymbolControl magic)
|
||||
{
|
||||
magic.Content = MagicSymbolConverter.ConvertToFrameworkElement(e.NewValue);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Symbol to show
|
||||
/// </summary>
|
||||
public object Symbol
|
||||
{
|
||||
get => GetValue(SymbolProperty);
|
||||
set => SetValue(SymbolProperty, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of <see cref="MagicSymbolControl"/>
|
||||
/// </summary>
|
||||
public MagicSymbolControl()
|
||||
{
|
||||
Focusable = false;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user