Use the Width/Height of parent object in XAML

Is there a way to make an object use the width and height of its parent without having to manually assign the same width and height values?

For instance, if you have a Canvas sized 100 x 100 and then you add a Rectangle to that Canvas, can you make the Rectangle automatically give itself the size 100 x 100?

Maybe something like:

<Canvas Width="100" Height = "100">
<Rectangle Stroke="Black" RadiusX="5" RadiusY="5" Width="*" Height="*"/>
</Canvas>

[615 byte] By [JamesLissiak] at [2008-2-14]
# 1

No, not in WPF/E. You will need a Grid or Flow panel that the full WPF has.

-mark
Program Manager
Microsoft
This post is provided "as-is"

MarkRideout at 2007-9-4 > top of Msdn Tech,Silverlight (formerly WPF/E),Silverlight (formerly WPF/E) Developer Issues...
# 2
Ah, ok. thanks.

Guess I'll just have to stop trying to be lazy and put all the sizes in manually :P

JamesLissiak at 2007-9-4 > top of Msdn Tech,Silverlight (formerly WPF/E),Silverlight (formerly WPF/E) Developer Issues...
# 3
I was also wondering why I couldn't use percentage as a size (in this case you would then just specify the height and width of the child as 100%)
Odegaard at 2007-9-4 > top of Msdn Tech,Silverlight (formerly WPF/E),Silverlight (formerly WPF/E) Developer Issues...
# 4

Right now we do not have a concept of layout, so there isn't a way for an element to dynamically size as a percentage of its host. It will be a while before we enable this.

-mark
Program Manager
Microsoft
This post is provided "as-is"

MarkRideout at 2007-9-4 > top of Msdn Tech,Silverlight (formerly WPF/E),Silverlight (formerly WPF/E) Developer Issues...