Mega Code Archive

 
Categories / VB.Net Tutorial / WPF
 

Fill rectangle with UniformToFill ImageBrush

<Window x: Class="WpfApplication1.Window1"     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"     Title="WPF" Height="300" Width="300">     <Canvas Margin="5">         <!--Fill rectangle with UniformToFill ImageBrush-->         <Rectangle Height="180" Width="50"                     Canvas.Top="5" Canvas.Left="5"                    Stroke="Black" StrokeThickness="1" >             <Rectangle.Fill>                 <ImageBrush ImageSource="c:\image.jpg" Stretch="UniformToFill"/>             </Rectangle.Fill>         </Rectangle>     </Canvas> </Window>