You can write a markup extension by getting the MarkupExtension class and implementing the ProvideValue method:
public class BooleanValueExtension : MarkupExtension
{
private readonly bool _value;
public BooleanValueExtension(bool value)
{
_value = value;
}
public override object ProvideValue(IServiceProvider serviceProvider)
{
return _value;
}
}
You can then use this using the binding syntax:
<Button CommandParameter="{local:BooleanValue True}" />
source
share