Mega Code Archive

 
Categories / VB.Net Tutorial / WPF
 

Button Background and DrawingBrush

<Window x: Class="Drawing.Drawings"     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"     Title="Drawings" Height="300" Width="300">   <Window.Resources>     <GeometryDrawing x:Key="Drawing" Brush="Yellow" >       <GeometryDrawing.Pen>         <Pen Brush="Blue" Thickness="3"></Pen>       </GeometryDrawing.Pen>       <GeometryDrawing.Geometry>         <PathGeometry>           <PathFigure IsClosed="True" StartPoint="10,100">             <LineSegment Point="100,100" />             <LineSegment Point="100,50" />           </PathFigure>         </PathGeometry>       </GeometryDrawing.Geometry>     </GeometryDrawing>   </Window.Resources>      <StackPanel Orientation="Horizontal" Margin="5">     <Button Width="30" Height="30">       <Button.Background>         <DrawingBrush Stretch="Uniform" Viewport="0,0 0.9,1" Drawing="{StaticResource Drawing}">                   </DrawingBrush>       </Button.Background>     </Button>   </StackPanel> </Window>