Files
Shrlalgo.RvKits/WPFluent/Converters/IconSourceElementConverter.cs

44 lines
1.5 KiB
C#

using WPFluent.Controls;
using System.Windows.Data;
namespace WPFluent.Converters;
/// <summary>
/// Converts an <see cref="IconSourceElement"/> to an <see cref="IconElement"/>.
/// </summary>
public class IconSourceElementConverter : IValueConverter
{
/// <summary>
/// Converts a value to an <see cref="IconElement"/>.
/// </summary>
/// <param name="value">The value to convert.</param>
/// <param name="targetType">The type of the binding target property.</param>
/// <param name="parameter">The converter parameter.</param>
/// <param name="culture">The culture to use in the converter.</param>
/// <returns>The converted <see cref="IconElement"/>.</returns>
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
{
if(value is IconSourceElement iconSourceElement)
{
return iconSourceElement.CreateIconElement();
}
return value;
}
/// <summary>
/// Converts an <see cref="IconElement"/> back to an IconSourceElement.
/// </summary>
/// <param name="value">The value to convert.</param>
/// <param name="targetType">The type of the binding target property.</param>
/// <param name="parameter">The converter parameter.</param>
/// <param name="culture">The culture to use in the converter.</param>
/// <returns>The converted IconSourceElement.</returns>
public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
{ throw new NotImplementedException(); }
}