0

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.

y0j0
  • 3,369
  • 5
  • 31
  • 52
  • 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 Feb 27 '15 at 17:59

1 Answers1

1

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">
kmatyaszek
  • 19,016
  • 9
  • 60
  • 65
  • probably it wont help, because I use a some external styles etc. But if I remove ViewBox, the Grid is stretched in common way – y0j0 Feb 27 '15 at 15:16