Users Pricing

articles

home / developersection / articles / label control in wpf

Label control in WPF

Anonymous User 12325 06 Apr 2011 Updated 07 Sep 2019

In WPF we can use Label control to show some messages to user such as result of calculation price of certain things, to show caption etc. We can use XAML <Label /> element to create a Label control in WPF. In this demonstration I will show you how to use Label control in WPF.

The following code snippets represent use of Label control in WPF
<Label x:Name="lblMessage" Content="Hello Dear! Welcome to the demonstration of Label control" VerticalAlignment="Center" HorizontalAlignment="Center" />
Output of the following code snippet is as follows

Label control in WPF

Changing Foreground and Background of a Label control

The following code snippet changes the foreground and background of label control.

<Label x:Name="lblMessage" Content="Hello Dear! Welcome to the demonstration of Label control" VerticalAlignment="Center" HorizontalAlignment="Center" Background="Aquamarine" Foreground="Blue" />
Out of the following code snippet is as follows

Label control in WPF

Applying style to a label control
<Label x:Name="lblMessage" Content="Hello Dear! Welcome to the demonstration of Label control" VerticalAlignment="Center" HorizontalAlignment="Center">
            <Label.Foreground>
                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                    <GradientStop Color="Black" Offset="0.325" />
                    <GradientStop Color="#A0C30030" Offset="0.52" />
                </LinearGradientBrush>
            </Label.Foreground>
            <Label.Background>
                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                    <GradientStop Color="Black" Offset="1" />
                    <GradientStop Color="#9B52A03D" Offset="0.455" />
                </LinearGradientBrush>
            </Label.Background>
 </Label>
The output of the following code snippet is as follows

Label control in WPF


I am a content writter !


1 Comments