How to fill a shape with an image in WPF

If you want to fill a shape with an image, suppose you have an ellipse on your form and you want to fill this ellipse with an image then you can use ImageBrush class that enable us to paint an area with an image. An ImageBrush paints an area with an ImageSource property. An ImageBrush is a type of TileBrush that defines its content as an image.


In the following example we draw an ellipse and fill with an image:

<Window x:Class="SimpleStyles.Window1"
   <ScrollViewer Height="187" Width="600">
        <Grid Height="173" Name="Grid1" Width="581" ShowGridLines="False">
                <Ellipse Height="150" Width="150" HorizontalAlignment="Left" Margin="36,11,0,5">
                        <ImageBrush ImageSource="Images/Tulips1.jpg" />