Is there a way to define a converter when using the DynamicResource
extension? Something in the lines of
<RowDefinition Height="{Binding Source={DynamicResource someHeight}, Converter={StaticResource gridLengthConverter}}" />
which unfortunately gives me the following excpetion:
A 'DynamicResourceExtension' cannot be set on the 'Source' property of type 'Binding'. A 'DynamicResourceExtension' can only be set on a DependencyProperty of a DependencyObject.
I know i am really late to this but what definitely works is using a BindingProxy for the DynamicResource like this
Then applying the converter to the proxy
I like the answer of mkoertgen.
Here is an adapted example for a IValueConverter proxy in VB.NET that worked for me. My resource "VisibilityConverter" is now included as DynamicResource and forwarded with the ConverterProxy "VisibilityConverterProxy".
Usage:
Code:
End Namespace
@Thomas's post is very close, but as others have pointed out, it only executes at the time the MarkupExtension is executed.
Here's a solution that does true binding, doesn't require 'proxy' objects, and is written just like any other binding, except instead of a source and path, you give it a resource key...
How do you create a DynamicResourceBinding that supports Converters, StringFormat?
Try something like that:
Markup extension:
XAML: