views:

37

answers:

1

I basically want certain parts of my window to not affect SizeToContent (things like a title bar) so that it appears to have no size and collapses. Is there a panel I can use to do this (like a ScrollViewer maybe?) or do I have to write my own?

+2  A: 

You need a control that will return (0,0) from MeasureOverride. Canvas will do this, but it may not have other behavior you want. You could also subclass an existing panel, like Grid, and just return an empty size:

public class ZeroGrid
    : Grid
{
    protected override Size MeasureOverride(Size constraint)
    {
        base.MeasureOverride(constraint);
        return new Size();
    }
}

That will behave like a Grid, so its content will stretch to its actual size, but it will always have a DesiredSize of zero so it won't affect SizeToContent.

Quartermeister