Tormod
Tormod

Reputation: 4573

How do I get the user controls to Resize themselves properly?

I feel bad about not getting this. But, although I have read several articles on measure pass and arrange pass and written several small programs, I still have a hard time with this.

It makes sense to me that any user control will have a "minimum size" (after which only possible solution would be to shrink it as a whole bitmap wise or add a scroll bar). It will also have a way to use any additional screen real estate given to it.

Ellipses have no minimum size and can collapse to size zero.

So, consider this example

<Grid>
    <StackPanel Orientation="Horizontal" Height="20">
        <Ellipse Fill="Blue"/>
        <Ellipse Fill="Green"/>
        <Ellipse Fill="BlueViolet"/>
    </StackPanel>
</Grid>

what is the least amount of xaml code needed to add to achieve the following effects:

Thank you.

Upvotes: 1

Views: 215

Answers (1)

brunnerh
brunnerh

Reputation: 184441

In most of those cases you probably want to use a UniformGrid with one column instead of a StackPanel. To force sizes use a Style which sets the MinHeight and MinWidth. If the uniformity is guaranteed to be "one-way" you can just bind the Width to the ActualHeight.

Upvotes: 1

Related Questions