Search This Blog

Wednesday, November 4, 2015

Label WPF Example

WPF > Controls  > ContentControl > Label

This control represents the text label for a control and provides support for access keys.

Example

The following example shows how to create a Label that has an access key and uses a binding to set the target.

<Window x:Class="WpfApplication2.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <TextBox Name="textBox" Margin="49,0,281,291"/>
        <Label Target="{Binding ElementName=textBox}">_Name</Label>
    </Grid>

</Window>