I am trying to create TypeConverter which will convert my custom type to ICommand if I am binding it to Button Command.
Unfortunetly WPF is not calling my converter.
Converter:
public class CustomConverter : TypeConverter
{
public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
{
if (destinationType == typeof(ICommand))
{
return true;
}
return base.CanConvertTo(context, destinationType);
}
public override object ConvertTo(
ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
{
if (destinationType == typeof(ICommand))
{
return new DelegateCommand<object>(x => { });
}
return base.ConvertTo(context, culture, value, destinationType);
}
}
Xaml:
<Button Content="Execute" Command="{Binding CustomObject}" />
Converter will be invoked if I will bind to content like:
<Button Content="{Binding CustomObject}" />
Any ideas how I can get TypeConverter to work?
IDestinationThingtoDestinationThingin the dependency property definition, and it will start working. - nmclean