views:

20

answers:

1

Is there a way to stretch a WPF Calendar control horizontally? The control will let me set HorizontalAlignment="Stretch", but that has the same effect as setting the property to "Center". It changes the width of the control, but the displayed calendar remains the same size in the center of the control. I'd like to stretch the displayed calendar to the edges of the control.

I seem to remember it could be done with a ViewPort, but I can't find anything that shows how to do it. Thanks for your help.

+2  A: 

I think you might be looking for Viewbox:

Defines a content decorator that can stretch and scale a single child to fill the available space.

If you make the Calendar a child of a Viewbox, it will apply a ScaleTransform to make it take up all the available space.

<Viewbox>
    <Calendar/>
</Viewbox>
Quartermeister
Thanks! Note for other users--the Viewbox stretches both horizontally and vertically. It can't stretch in just one direction, such as horizontally.
David Veeneman