How do I escape a comma when using a markup extension?

1.9k views Asked by At

The value of the second parameter of the markup extension I am using is a string containing some commas and I don't want those commas to be interpreted as parameter separators by the xaml interpreter / parser, but that the whole string as such including the commas is used as value.

Here is an example:

<SomeControl SomeProperty="{Wpf:MyExtension MyFirstParameter, 
                                            MySecondParameter, being a string, containing some commas.}" />

Google didn't help, I found some similar issues but none apply to this problem:

1

There are 1 answers

2
Samuel Slade On BEST ANSWER

You can use single quotes to encapsulate a string; so your mark-up should look something like:

<SomeControl SomeProperty="{Wpf:MyExtension MyFirstParameter, 
                           'MySecondParameter, being a string, containing some commas.'}" />

I'm not sure whether you will also need the {} escape sequence mark-up.