Hello I have a Binding that I am using along with a converter, I want the parameter that is transferred to the converter should be an empty string. Is there a way I can pass it via an inline binding?
+2
A:
Instead of defining the binding in a single line:
<Control Binding={Property, Converter={StaticResource someConverter}, ConverterParameter={StaticResource someParameter}} />
You can define it multi-line and specify attributes individually:
<Control>
<Control.Binding>
<Binding Path="Property" Converter="{StaticResource someConverter}" ConverterParameter="" />
</Control.Binding>
</Control>
Pretty sure that'll do what you're looking for.
CMerat
2009-10-30 11:45:13
+5
A:
If you want to do it inline, you can use the static String.Empty property. You need to add a namespace definition for clr-namespace:System to use it.
In your Window definition (or whichever control you're using):
xmlns:System="clr-namespace:System;assembly=mscorlib"
Then you can use something like this:
<ContentControl Content="{Binding Converter={StaticResource someConverter}, ConverterParameter={x:Static System:String.Empty}}" />
mjeanes
2009-10-30 12:54:56
Personally I think this is a little better than using the multiline version because people tend to see Converter="" as an unset property (probably one that used to be set and got missed during a refactor) and delete it.
Bryan Anderson
2009-10-30 14:48:06
+2
A:
You can actually use single quotes inline to pass an empty string, like so:
<ContentControl Content="{Binding Converter={StaticResource someConverter}, ConverterParameter=''}" />
Tom Goff
2009-11-16 14:41:45