tags:

views:

75

answers:

1

I'm attempting to draw a set of images in and Image in WPF, potentially off from top left, but no matter what I do, either the Image, the DrawingImage or the DrawingGroup are causing the image that is closest to the top left corner to default to the top left corner of the image.

Here's the code:

XAML:

<Canvas Grid.Column="1" Name="Canvas">
    <Image Name="imgLevel">
        <Image.Source>
            <DrawingImage>
                 <DrawingImage.Drawing>
                      <DrawingGroup>
                           <ImageDrawing Rect="120, 120, 100, 100" ImageSource="" />
                           <ImageDrawing Rect="300, 300, 100, 100" ImageSource="" />
                       </DrawingGroup>
                 </DrawingImage.Drawing>
            </DrawingImage>
        </Image.Source>
    </Image>
</Canvas>

No matter what I set the coordinates to for the first ImageDrawing, it's always in the upper left corner.

Is there a way to override this behaviour? More importantly, I eventually want to be able to specify negative numbers to that Rect. Is this possible?

A: 

Is there any reason you can't use the Canvas.Left and Canvas.Top attached properties on the Image control? Like this:

<Canvas Name="Canvas" Grid.Column="1">
    <Image Canvas.Left="-5" Canvas.Top="-10" Name="imgLevel">
        <Image.Source>
        </Image.Source>
    </Image>
</Canvas>
cplotts
Eventually I'm hoping to have multiple images which will be added / removed from the drawing group when they come in and out of bounds.
Jeff