Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use quote " character in XAML binding?

Tags:

quotes

wpf

xaml

I'm trying to do this:

<TextBlock Text="{Binding Path=Text, 
           Converter={StaticResource stringFormatConverter}, 
           ConverterParameter='\"{0}\"'}" />

But this is apparently not the way to get a quote into a XAML binding string.

What is the appropriate way to get "\"{0}"\" to work here?

like image 786
Alex Baranosky Avatar asked Sep 02 '09 11:09

Alex Baranosky


People also ask

What is {} in XAML?

{} Escape sequence / markup extensionProvides the XAML escape sequence for attribute values. The escape sequence allows the subsequent values in the attribute to be interpreted as a literal.

How do you pass quotes from the command line?

To pass an argument whose first character is @ , surround that argument with single or double quotes, otherwise it will be taken as a name of a response file which holds the actual command line.

How do you write in XAML?

Syntax Rules for Object Element It is because in XML, the value of the attributes must be a string, while in XAML, it can be a different object which is known as Property element syntax. The syntax of an Object element starts with a left angle bracket (<) followed by the name of the object, e.g. Button.


1 Answers

You have two options:

"&quot;{0}&quot;"
'"{0}"'

This is explained here: http://msdn.microsoft.com/en-us/library/ms748250.aspx

In your example (I couldn't see what you were trying to do at first), you'll probably want to do:

...='&quot;{0}&quot;'
like image 108
Daniel Martin Avatar answered Sep 21 '22 03:09

Daniel Martin