XAML ImageBrush
An image brush uses an image as fill color to fill graphics objects such as a recntagle, ellipse, and path. This article shows how to use ImageBrush in XAML.
An image brush uses an image as fill color to fill graphics objects such as a rectangle, ellipse, and path. The <ImageBrush/> represents the image brush in XAML. The BitmapSource property represents the image used to fill the brush.
The following code creates a brush with sunset.jpg. Once a brush is created, you can use it to fill graphics objects.
<ImageBrush BitmapSource="C:\sunset.jpg" />
For example, the following code fills a rectangle with an ImageBrush.
<Rectangle Width="200" Height="100" Stroke="Black" StrokeThickness="3">
<Rectangle.Fill>
<ImageBrush BitmapSource="C:\sunset.jpg"
/>
</Rectangle.Fill>
</Rectangle>
|
The output looks like Figure 1.
Image 1. Rectangle filled with an image brush.
Further Readings
You may also want to read these related articles.
Ask Your Question
Got a programming related question? You may want to post your question here