2021-12-06 17:54:46 +01:00
|
|
|
using System;
|
2022-08-05 21:30:57 +02:00
|
|
|
using System.ComponentModel;
|
2021-12-06 17:54:46 +01:00
|
|
|
using System.Globalization;
|
|
|
|
|
#if WINUI
|
|
|
|
|
using Microsoft.UI.Xaml.Data;
|
|
|
|
|
#elif UWP
|
|
|
|
|
using Windows.UI.Xaml.Data;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
namespace SampleApplication
|
|
|
|
|
{
|
2022-08-05 21:30:57 +02:00
|
|
|
public class DoubleTriggerConverter : IValueConverter
|
2021-12-06 17:54:46 +01:00
|
|
|
{
|
2022-08-05 21:30:57 +02:00
|
|
|
public double Trigger { get; set; }
|
|
|
|
|
public object TriggerValue { get; set; }
|
|
|
|
|
public object DefaultValue { get; set; }
|
|
|
|
|
|
2021-12-06 17:54:46 +01:00
|
|
|
public object Convert(object value, Type targetType, object parameter, string language)
|
|
|
|
|
{
|
2022-08-05 21:30:57 +02:00
|
|
|
var converter = TypeDescriptor.GetConverter(targetType);
|
2022-08-05 18:54:19 +02:00
|
|
|
|
2022-08-05 21:30:57 +02:00
|
|
|
return (double)value == Trigger ? converter.ConvertFrom(TriggerValue) : converter.ConvertFrom(DefaultValue);
|
2021-12-06 17:54:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public object ConvertBack(object value, Type targetType, object parameter, string language)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
|
|
|
|
{
|
|
|
|
|
return Convert(value, targetType, parameter, "");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
|
|
|
|
{
|
|
|
|
|
return ConvertBack(value, targetType, parameter, "");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|