How to set an Image as Background of a Label

To set an image as background of a Label, we can set an image as the Background of the Label. The following code snippet sets the background of a Label to an image. The code also sets the opacity of the image.

<Window x:Class="LabelSample.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 Name="LayoutRoot">

        <Label Name="McLabel" Width="240" Height="30"

               Foreground="DarkBlue"

               FontFamily="Verdana" FontSize="14" FontWeight="Bold">

            I am a label control

            <Label.Background>

                <ImageBrush ImageSource="Flower.jpg" Opacity="0.6"/>

            </Label.Background>

        </Label>

    </Grid>

</Window>