I’m trying to write a custom MarkupExtension that allows me to use my own mechanisms for defining a binding, however when I attempt to return a MultiBinding from my MarkupExtension I get the above exception.
I have:
<TextBlock Text="{my:CustomMarkup ...}" />
CustomMarkup returns a MultiBinding, but apparently Text doesn’t like being set to a MultiBinding. How come it works when I say:
<TextBlock>
<TextBlock.Text>
<MultiBinding ... />
</TextBlock.Text>
</TextBlock>
But it doesn’t work the way I’m doing it?
Don’t return the
MultiBindingitself. Instead, return the result ofMultiBinding.ProvideValue.BTW, what exactly are you doing in your markup extension ? Perhaps you could just inherit from
MultiBinding, if you don’t need to overrideProvideValue(which is sealed). You can achieve almost anything by just setting the appropriateConverterand other properties