Working with Brushes in WPF: Part 4 in VB.NET
In this article you learn about the all types of brushes and how to working with them in WPF.
Brushes: As you learn in my previous article part 1, part 2, part 3 a brush is used to describe the background of a button, the foreground of text, and the fill of a shape and all brushes classes are inherit from System.Windows.Media.Brush and give you more exotic effects.
Here we discuss about the third Brush class that is ImageBrush.
ImageBrush: An ImageBrush paints an area with a ImageSource it allows you to fill an area with a bitmap image. You can use most common file types, including BMP, PNG, GIF, and JPEG files. You identify the image you want to use by setting the ImageSource property.
Example of an ImageBrush
Title="MainWindow" Height="350" Width="525">
<Rectangle Width="100" Height="100">
<ImageBrush ImageSource="logo.gif" />
Dim Rectangle1 As New Rectangle()
Rectangle1.Width = 100
Rectangle1.Height = 100
' Create an ImageBrush and use it to
' paint the rectangle.
Dim Brush As New ImageBrush()
Brush.ImageSource = New BitmapImage(New Uri("logo.gif))
Rectangle1.Fill = Brush
Hope this article will help you understand the working of ImageBrush in WPF. Remaining types of brushes will explain in my next articles.