ImageBrush In WPF

By Mahak Gupta Mar 03, 2012
Here we take an example to paint an Image on a TextBlock with the help of ImageBrush Property.
Download Files: WpfApplication1.rar
Here we take an example to paint an Image on a TextBlock with the help of ImageBrush Property.

<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>
        <StackPanel>
            <!--Code For TextBlock without an ImageBrush -->
            <TextBlock
FontSize="32"
FontFamily="Arial"
FontWeight="Bold">
Mahak Gupta
</TextBlock>
            <!--Code For TextBlock with an ImageBrush -->
            <TextBlock
FontSize="32"
FontFamily="Arial"

FontWeight="Bold">
Mahak Gupta
<!-- Add an Image as the foreground -->
<TextBlock.Foreground>
<ImageBrush ImageSource="Images/28092011950.jpg"
Stretch="Fill"/>
</TextBlock.Foreground>
</TextBlock>
</StackPanel>

    </Grid>
</Window>

1.png
Mahak Gupta

My name is Mahak Gupta. I am a C# Corner MVP.

COMMENT USING

PREMIUM SPONSORS

Hire Mobile & Web Developer on demand. 100% satisfaction. Try for 1 week or Money Back. Local and remote developers available all over USA.

Latest Blogs