views:

205

answers:

0

I have a canvas like this:

<Canvas>
    <Rectangle Fill="Blue" Opacity="0.5" Canvas.ZIndex="1" />
    <Grid Canvas.ZIndex="0" >
            ...bla bla bla...
    </Grid>
</Canvas>

I need the Width/Height of the Canvas to just stretch to the Width/Height of the Grid, but then I need the Width/Height of the Rectangle to stretch to match. Is this possible? It seems I am able to control the size of the Canvas by setting the size of the content in the Grid, but I was hoping that the size of the Rectangle (since I don't set it explicitly) would just snap to be as big as its container, but it seems that doesn't work with Canvas?

Please help if you can.

related questions