SSgi88 SSgi88 - 3 months ago 12
C# Question

How do I pass string with spaces to converterParameter?

My sample code is below.

I want to pass 'Go to linked item' to

ConverterParameter
but I can't because the string has spaces.

Text="{Binding Value,
Source={x:Static local:Dictionary.Instance},
Converter={StaticResource StringConverter},
ConverterParameter=Go to linked item, Mode=OneWay}"


How can I do this?

Answer

Option 1

Text="{Binding Value, 
        Source={x:Static local:Dictionary.Instance}, 
        Converter={StaticResource StringConverter}, 
        ConverterParameter='Go to linked item', Mode=OneWay}"

Option 2

If you want to use this in multiple places add a string resource.

<sys:String x:Key="GoToLink">Go to linked item</sys:String>

And pass the resource key.

ConverterParameter={StaticResource ResourceKey=GoToLink}}