0
votes

I'm using ViewBox control to scale my forms in winstore application. I need stretch controls inside ViewBox but common HorizontalAlignment="Stretch" does not work

This is my code :

    <Viewbox Margin="20" Grid.Row="1" Grid.Column="2" HorizontalAlignment="Stretch">
       <Grid HorizontalAlignment="Stretch" VerticalAlignment="Top" >
...

This is result :

enter image description here

ViewBox is grey rectangle, Grid is selected (blue rectangle), TextBoxes do not have set width.

Can you advise me, how to solve this? I dont want to set width explicitly.

1
As kmatyaszek said, you're not really showing enough XAML. Seeing that you have your Margin set, and its wrapped in another grid, which might be wrapped in something like a StackPanel, etc., we will never be able to reproduce the problem; so you probably won't get your question answered until you give us more of the visual tree. - Kcvin

1 Answers

1
votes

Try set Stretch property to Fill (msdn):

<Viewbox Margin="20" Grid.Row="1" Grid.Column="2" HorizontalAlignment="Stretch" 
           Stretch="Fill">
      <Grid HorizontalAlignment="Stretch" VerticalAlignment="Top">