Label Control in WPF
Code for label control
<Label Name="Label1"
Content="Hello! I am Label Control"
Width="200" Height="30"
Canvas.Left="10" Canvas.Top="10"
FontSize="14" FontFamily="Georgia"
FontWeight="Bold"
Background="Black"
Foreground="Orange"
VerticalAlignment="Center"
HorizontalAlignment="Center"/>
Output
Adding Contents to a Label Control
The Content property of the Label control allows you to set any other controls as the content of a Label control. The code snippet in Listing 3 adds some ellipse controls to a Label control.
<Window x:Class="WpfApplication1.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300">
<Grid Width="331.785">
<Label Canvas.Left="10" Canvas.Top="50">
<StackPanel Orientation="Horizontal">
<Ellipse Width="100" Height="100" Fill="Red" />
<Ellipse Width="80" Height="80" Fill="Orange" />
<Ellipse Width="60" Height="60" Fill="Yellow" />
<Ellipse Width="40" Height="40" Fill="Green" />
<Ellipse Width="20" Height="20" Fill="Blue" />
<Ellipse Width="15" Height="15" Fill="Indigo" />
<Ellipse Width="10" Height="10" Fill="Violet" />
</StackPanel>
</Label>
</Grid>
</Window>
Output-
Formatting a Label
The BorderBrush property of the Label sets a brush to draw the border of a Label. You may use any brush to fill the border.
Setting Image as Background of a Label
<Label Height="28" HorizontalAlignment="Left" Margin="10,10,0,0"
Name="label1" VerticalAlignment="Top" Width="120"></Label>
<Image Source="F:\Anilnewtopic\images\border1.JPG" Stretch="Fill"
Height="18" Margin="84.537,94.536,83.628,0" VerticalAlignment="Top">
</Image>
Output
No comments:
Post a Comment