Search code examples
wpfxaml

Cannot see _ (underscore) in WPF content


A very simple question:

Why I cant see _ (underscore) in WPF content?

For instance the content of

<Label Content="test_t" Name="label2"  />

is shown as "testt" (with the underscore not shown).


Solution

  • Labels support mnemonics (i.e. you can use ctrl+(key) to give them focus). You define the mnemonic key using an underscore.

    http://www.charlespetzold.com/blog/2006/01/061004.html

    If you want to see underscores, replace single underscores with double underscores.