EDIT: TL/DR
You can use custom markup extensions in PriorityBinding
. It likely gets highlighted with an error message and the designer might not show it at design time but it works like a charm at runtime. Seems to be an issue with the XAML designer or some other internal component.
Well I have certain scenarios in our software where I need to display a translated string in case the binding returns null. Here my production number is set only at a certain point and until then I want to show "Unknown" translated in the user's language. For this we're using a custom markup which returns a binding to an intermediate object that supports translation.
Sadly MarkupExtension
is inherited by BindingBase
and not the other way around. So since PriorityBinding
expects a collection of BindingBase
I can't add my translation markup as fallback binding.
This is what I tried:
<PriorityBinding>
<Binding Path="ProductionNumber" />
<l:Translate Key="Unknown" Context="Common" />
</PriorityBinding>
So does anyone know how to work around this? Using PriorityBinding
would be the easiest way to do this. Of course I could use a converter for this but then I would eliminate some essential features implemented in the markup which basically renders it useless.