Search code examples
wpfmultibinding

WPF MultiBinding same converter with different binding path


I have ten UI Controls of the same type in a UI and all will be using same multi binding converter.

The problem is I can not create a common style for multibinding which I can apply to all UI controls to avoid duplicate code, as each control will use a different binding property to pass as a Binding to converter.

Is there any way in WPF we can avoid duplicate code for this scenario?


Solution

  • You can extend MarkupExtension, which allows you to define a custom Converter wrapper and then just call it with the 2 Paths.

    Edit: in your case it's probably best to inherit directly from MultiBinding and set sensible defaults in the constructor.