tags:

views:

1993

answers:

2

I have a Viewbox that is using Stretch=Uniform in order to not distort the content. However... when the frame window is wider or taller than the content, the Viewbox content is always centered.

I cannot seem to find any content alignment options on the Viewbox.

Is there a way to do this?

+1  A: 

According to MSDN the Viewbox is used to stretch the child elements. Since the child elements would be stretched, you would have to set the content alignment of the children.

You may want to look at this for more information on the Viewbox: http://stackoverflow.com/questions/288954/how-do-i-keep-aspect-ratio-on-scalable-scrollable-content-in-wpf

a_hardin
I can set HorizontalAlignment and VerticalAlignment on the child object and it still centers when the Viewbox scales it.
Jeff B
+2  A: 

Try VerticalAlignment and HorizontalAlignment. VerticalAlignment="Top" HorizontalAlignment="Left" on your viewbox will cause it to be anchored to the Top and left side.

<Grid>
    <Viewbox VerticalAlignment="Top" HorizontalAlignment="Left">

If you want it to completely fill (but keep it uniform) you can use Stretch="UniformToFill".

John Z