Tip: Curly brackets in XAML Binding’s ConverterParameter

While working on an UWP app, I wanted to create a string.Format  based value converter, so that I could provide a format string in the ConverterParameter , augment the data bound value with it and use the result as a key for a localized string from resources. When I tried to build the project however, I was met with the following cryptic error message:

Child node "2" exited prematurely. Shutting down. 
Diagnostic information may be found in files in the
temporary files directory named MSBuild_*.failure.txt.

Although the nor the error nor the generated diagnostic were too helpful, because I have mostly added just the new XAML binding, I suspected the error must be hidden there.

   Converter={StaticResource TypeNameLocalizingConverter}, 

As you might expect, it is not possible to use curly brackets directly inside the XAML binding expression.

Solution is simple – escaping with backslash.

   Converter={StaticResource TypeNameLocalizingConverter}, 

With this little change, the code will compile and the value converter works as expected.

Buy me a coffeeBuy me a coffee

1 thought on “Tip: Curly brackets in XAML Binding’s ConverterParameter”

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>


This site uses Akismet to reduce spam. Learn how your comment data is processed.