A child element can ask for more space. Whether that is honored by the parent element is up to the parent element.
MeasureCore only calls MeasureOverride on this
. You're only getting a very small part of the story. The Layout System starts with calling Measure
on the topmost Panel
in the tree of elements, which calls MeasureCore
on this
. However, MeasureCore
in FrameworkElement
calls MeasureOverride
in a couple of places.
Where are you seeing it cap between 0 and availableSize?
Edit: Re: "well, the last line of MeasureCore..."
Like I said, you're looking at a small part of all that goes on.
- All controls have 1 very common way to request more space than they actually need:
Margin
. You'd have to write a custom control to request even more space than that.
- The constraints you see in
MeasureCore
, from what I can tell, have to do with the MinWidth
/MinHeight
and MaxWidth
/MaxHeight
limits, if they are set.
So yeah, a control -- like the documentation says -- can request more space than is needed. None of the default controls seem to do this aside from their Margin
s, and containers such as panels don't have to respect it. Most circumstances don't take advantage of what you read in the documentation because in most circumstances, it wouldn't make sense from either the perspective of the parent of the child.
If you created a UserControl
, got rid of the Width
and Height
values in the XAML and override MeasureOverride
to return an arbitrary Size
, then place an instance of it in a Canvas
, you would see it display at the Size
you returned.
This feature of the layout system may be of use if you are creating custom panels and custom controls or user controls, but otherwise probably not. But it is there. The documentation is correct.