Suppose you want to fill a shape with an image in WpfApplication. Draw an image to your window with the help of toolbox as you see in the following example we draw an ellipse and now want fill it with an image, lets see the following code to do that:
<Window x:Class="WpfApplication1.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="WPF" Height="400" Width="400"> <Canvas Margin="5"> <!--Define a static ImageBrush resource--> <Canvas.Resources> <ImageBrush x:Key="IB1" ImageSource="c:\flower.jpg" /> </Canvas.Resources> <!--Fill ellipse using static ImageBrush resource--> <Ellipse Height="260" Width="260" Canvas.Top="20" Canvas.Left="50" Stroke="Black" StrokeThickness="1" Fill="{StaticResource IB1}" /> </Canvas> </Window>
OUTPUT
Fill a shape with image in WPF Application
WPF Brushes in VB.NET