Posts Tagged ‘ImageBrush’

imagebrush.jpg (36 KB)

<UserControl x:Class="ImageBrushTest.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480">
  <Grid x:Name="LayoutRoot">
      <Canvas>
            <Rectangle RadiusX="30" RadiusY="30" Fill="AliceBlue" Stroke="Gray" StrokeThickness="5" Canvas.Left="5" Canvas.Top="5" Width="360" Height="360" />
            <Ellipse Width="330" Height="330" Canvas.Left="20" Canvas.Top="20" Stroke="Coral" StrokeThickness="10">
                <Ellipse.Fill>
                    <ImageBrush Stretch="Uniform" ImageSource="bird.png" />
                </Ellipse.Fill>
            </Ellipse>
        </Canvas>
  </Grid>
</UserControl>

Image file should be in the same folder as the XAP file (“ClientBin” folder). If it is not the case, you must specify the path to the file (ie http://www.yoursite.com/images/bird.png).
Actually, the XAP file is a ZIP file with different extension. You can change its extension and unzip it.