Applying an ImageBrush

You can fill a visual element with an image file by using the ImageBrush brush. This object is useful even if you want to fill text with image textures. The following code snippet shows how to apply an ImageBrush as a button background and as the text foreground color:

<StackPanel Grid.Row="3" Orientation="Horizontal">    <Button Width="100" Margin="5" Content="Hello!"        Foreground="Yellow">        <Button.Background>            <ImageBrush Opacity="0.5"                ImageSource=          "/StylesBrushesTemplatesAnimations;component/Images/Avatar.jpg" />        </Button.Background>    </Button>    <TextBlock Margin="5"               FontFamily="Segoe UI" FontSize="40" Text="Hello!"

Get Visual Basic 2015 Unleashed now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.