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?
You can actually use single quotes inline to pass an empty string, like so:
<ContentControl Content="{Binding Converter={StaticResource someConverter}, ConverterParameter=''}" />
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}}" />
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With