wabbajack/Wabbajack.App.Wpf/Converters/CommandConverter.cs
2022-03-13 16:47:30 -06:00

36 lines
906 B
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
using ReactiveUI;
namespace Wabbajack
{
public class CommandConverter : IBindingTypeConverter
{
public int GetAffinityForObjects(Type fromType, Type toType)
{
if (toType != typeof(ICommand)) return 0;
if (fromType == typeof(ICommand)
|| fromType == typeof(IReactiveCommand))
{
return 1;
}
return 0;
}
public bool TryConvert(object from, Type toType, object conversionHint, out object result)
{
if (from == null)
{
result = default(ICommand);
return true;
}
result = from as ICommand;
return result != null;
}
}
}