Resizing a collection of Paths in WPF

Since my post "Cool XAML objects from Clipart" i have been playing with these Metafile images as XAML. 

One of my first challenges was resizing looking at the hundreds of paths i was thinking this was going to be a real bear!

Of course i was forgetting that WPF solves this problem! 

From the documentation i missed the following text:


When you define a new Visual for a VisualBrush and that Visual is a UIElement (such as a panel or control), the layout system runs on the UIElement and its child elements


The important piece of course being "Child Elements" so all i had to do to resize the image is create a visualbrush of the canvas that contained all these paths and fill something larger or smaller with this brush.


<Canvas x:Name="Stove" Width="255" Height="345" Canvas.Left="0" Canvas.Top="0">
<Path x:Name="Path" Width="238.478" Height="330.473" Canvas.Left="7.95565" Canvas.Top="6.45703" Stretch="Fill" Fill="#FFFFFFFF" Data="M 246.434,336.93L 246.434,111.359L 216.988,65.9872L 216.988,6.45703L 37.5632,6.45703L 37.5632,65.9872L 7.95565,111.359L 7.95565,336.93L 246.434,336.93 Z "/>

(lots of elements removed)

Then to resize the image create a visualbrush from the stove canvas defined above and fill a border with it (see below).


<Border Grid.Column="1" Grid.Row="1" Grid.ColumnSpan="2" Height="80" Margin="64.0728162930267,0,138.533976097669,90.5439999999999" Grid.RowSpan="2" VerticalAlignment="Bottom">
        <VisualBrush Visual="{Binding ElementName=stove}" />


Skip to main content