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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.