In my project I want to display a small logo on the side of a custom control. Since I have no canvas I thought maybe a Visual Brush would be a good Idea to place the logo in the background.

        <Rectangle Width="200" Height="200" Fill="Red" />

But the Rectangle I am using right now is not 200x200. It takes the complete available space. Thats not what I want. I also tried a Viewbox and set the stretch property but the result is the same because in the end I don't need a simple Rectangle but a canvas with many path objects as children. A Viewbox supports only one child.

This there any way to get around this problem?


Add Grid and this Set Vertical alligment to Top and Horizontal alignment to Right Sample code

  <VisualBrush x:Key="myVisual">
                <Rectangle Height="200" Width="200" Fill="Red" HorizontalAlignment="Right"  VerticalAlignment="Top" ></Rectangle> 
+1  A: 

You need to set TileMode, Stretch, AlignmentX and AlignmentY properties on your VisualBrush:

<VisualBrush TileMode="None" Stretch="None" AlignmentX="Left" AlignmentY="Top">
            <Rectangle Height="200" Width="200" Fill="Red"></Rectangle> 
Mark Heath
Works perfectly. Thanks a lot.