#846 – Including an Underscore Character in a Label

When you include an underline ‘_’ character in the Content property of a Label, the underline character will be used to determine the access key for the label.  If you want to actually have a underline character show up in your user interface, you need to use a double underline ‘__’ sequence for the underline character.

    <StackPanel Orientation="Horizontal">
        <Label Content="Enter Your Super__Cool _Nickname"
               Target="{Binding ElementName=txtName}"
               VerticalAlignment="Center"/>
        <TextBox Name="txtName" Width="150"
                 VerticalAlignment="Center"/>
    </StackPanel>

846-001

Advertisement