<タイル描画>
縦横16ドットの画像をタイリングして256×256の領域を塗りつぶす
   <StackPanel>
       <Rectangle Width="256" Height="256">
           <Rectangle.Fill>
               <ImageBrush ImageSource="checker.jpg" Viewport="0,0,16,16" TileMode="Tile" ViewportUnits="Absolute"/>
           </Rectangle.Fill>
       </Rectangle>
   </StackPanel>

<リソースからイメージブラシを利用してバックグランドを塗りつぶす>
   <StackPanel>
       <StackPanel.Resources>
           <ImageBrush x:Key="checkerBrush" ImageSource="Checker.jpg" Stretch="None" TileMode="Tile" ViewportUnits="Absolute" Viewport="0,0,16,16"/>
       </StackPanel.Resources>
       <Button Width="200" Height="50" Background="{DynamicResource checkerBrush}"/>
   </StackPanel>

<DrawingBrush内にEllipseGeometry等で描画して、そのブラシを素材にタイリングしボタンのバックグランドを塗りつぶす>
   <Grid>
       <Button Content="A Button" Width="200" Height="200">
           <Button.Background>
               <DrawingBrush Stretch="None" TileMode="Tile" Viewport="0,0,25,50" ViewportUnits="Absolute">
                   <DrawingBrush.Drawing>
                       <GeometryDrawing Brush="Bisque">
                           <GeometryDrawing.Geometry>
                               <GeometryGroup>
                                   <EllipseGeometry RadiusX="12.5" RadiusY="25" Center="25,50"/>
                                   <EllipseGeometry RadiusX="12.5" RadiusY="25" Center="50,50"/>
                                   <EllipseGeometry RadiusX="12.5" RadiusY="25" Center="75,50"/>
                               </GeometryGroup>
                           </GeometryDrawing.Geometry>
                           <GeometryDrawing.Pen>
                               <Pen Thickness="1" Brush="Gray"/>
                           </GeometryDrawing.Pen>
                           </GeometryDrawing>
                   </DrawingBrush.Drawing>
               </DrawingBrush>
           </Button.Background>
           </Button>
   </Grid>

<ビジュアルブラシで領域を塗りつぶす(エレメントやコントロールなどほぼすべてのグラフイカルオブジェクトを素材にして描画する。素材として利用されたコントロールの機能は機能しなくなる)>
   <Grid>
       <Rectangle Width="150" Height="150" Stroke="Black" Margin="5,0,5,0">
           <Rectangle.Fill>
               <VisualBrush Stretch="None">
                   <VisualBrush.Visual>
                       <StackPanel Background="White">
                           <Rectangle Width="25" Height="25" Fill="Red" Margin="2"/>
                           <TextBlock FontSize="10pt" Margin="2">Hello, World!</TextBlock>
                           <Button Margin="2">A Button</Button>
                       </StackPanel>
                   </VisualBrush.Visual>
               </VisualBrush>
           </Rectangle.Fill>
           </Rectangle>
   </Grid>
最終更新:2012年10月02日 00:57