Template_Wpf ( WPF )

Objectives:
  • The Viewport property specifies the tile size for a TileBrush.
Step:1 Create a New project

Add an image to this project

Step:2 Edit XAML markup code of MainWindow.xaml

<Window x:Class="WpfViewPort1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Window.Resources>
<ImageBrush x:Key="TileBrush1" TileMode="Tile"
ViewportUnits="Absolute" Viewport="0 0 32 32"
ImageSource="green_twig.gif" Opacity="0.3">
</ImageBrush>
</Window.Resources>
<Grid>
<Button Background="{StaticResource TileBrush1}" Padding="5" Name="somebutton"
FontWeight="Bold" FontSize="14" Margin="31,49,333,225" Width="139" Height="37"
>A Tiled Button</Button>
<Line X1="30" Y1="50" X2 ="250" Y2="50"
Stroke="Blue" StrokeThickness="10"
StrokeDashArray="5,3" Margin="0,49,0,195" />
<Canvas Height="100" HorizontalAlignment="Left"
Margin="31,134,0,0" Background="{StaticResource TileBrush1}"
Name="canvas1" VerticalAlignment="Top" Width="219" >
<Label Content="This is a Label in a canvas"/>
</Canvas>
</Grid>
</Window>

 

 

Step:3  Runtime View