I have the following problem.
I want to delimit a string be a certain symbol. This could be a comma, a space, a tab or something else.
I store that delimiter symbol in my dependency property Delimiter.
In my WPF code I have the following radio button which should be checked if Delimiter belongs to that radio button.
This is the WPF code:
<RadioButton IsChecked="{Binding ElementName=view, Path=Delimiter, Converter={StaticResource MyConverterToCheckForEquality}, ConverterParameter=\t}" Tag="\t" />
If I check out the parameter in my converter the value is ‘t’.
I wanted ‘\t’ so I tried the following options:
- \t
- \\t
- \\\t
- ‘\t’
- ‘\\t’
- ‘\\\t’
- & #92;t
- ‘& #92;t’
- {}{\t}
- ‘{}{\t}’
(Note: I added extra spaces and backslashes to display it here correctly).
The result is very saddening… Triple and Double backslash gives me double backslash, Single gives me none. & #92; also gives me zero backslashes.
Maybe the most frustrating thing is that when I use the Tag property to set the delimiter \t just works fine and is not extra escaped in the process…
Can somebody explain why this happens, why none of these options worked and how to fix it?
UPDATE
When I use a multibinding within a multidatatrigger the result is diffrent:
<Binding ElementName="view" Path="Delimiter" Converter="{StaticResource MyConverterToCheckForEquality}" ConverterParameter="\\\t" />
The parameter value in my converter is now ‘\\\\\\t’, however I still can’t make it work.
I can replace the value but that would mean I have to use a different variable in my code behind file, which would be pretty ugly. I guess there is no other solution though.
Try this:
	represents\t(#9 is the ASCII equivalent of horizontal tab)I tested it by passing it into my converter as the converter parameter, and it shows up correctly. Here’s my test code:
XAML:
C# codebehind:
When I run this, the window shows a TextBox with the text “Success!”