I want to custumize my caliburn conventions to handles a custom control that here we can call BaseText.
If one of controls in use that derive from BaseEdit has the Tag property in xaml set equals to custom converter name, I want to attach this converter to binding.
I have tried as show above:
I can achieve my goal with a custom attribute on view-model, but I prefer to do this via ConventionManager.AddElementConvention. It's possible?
Thanks in advance.
If one of controls in use that derive from BaseEdit has the Tag property in xaml set equals to custom converter name, I want to attach this converter to binding.
I have tried as show above:
ConventionManager.AddElementConvention<BaseText>(BaseText.EditValueProperty, "Text", "EditValueChanged")
.ApplyBinding = (viewModelType, path, property, element, convention) =>
{
var bindableProperty = convention.GetBindableProperty(element);
if (!ConventionManager.SetBindingWithoutBindingOrValueOverwrite(viewModelType, path, property, element, convention, bindableProperty))
return false;
if ((string)element.Tag == "DateTimeToTimeSpanConverter")
{
Binding binding = BindingOperations
.GetBindingExpression(element as DependencyObject, bindableProperty)
.ParentBinding;
binding.Converter = customConv;
}
return true;
};
but statement binding.Converter = customConv
raise an error. Where is my mistake?I can achieve my goal with a custom attribute on view-model, but I prefer to do this via ConventionManager.AddElementConvention. It's possible?
Thanks in advance.