Question

I have a WPF window with a Set on menu options on the top and a "Next" and "Previous" button on the bottom. In the middle of the window, I have a scroll viewer around a tab control in case the data in the tab control exceeds the window height. However, I would like to have m WPF move the buttons on the bottom and expand the middle if a user maximizes their window.

Any suggestions on where to begin?

Était-ce utile?

La solution

If I understand your question correctly, you would like the top and bottom of your window to remain a fixed size, but allow the middle section to grow when the window is expanded? If you are using a Grid layout, then you can accomplish that by the following:

<Grid>
  <Grid.RowDefinitions>
    <RowDefinition Height="30" />
    <RowDefinition Height="1*" />
    <RowDefinition Height="30" />
  </Grid.RowDefinitions>
  <your controls go here>
</Grid>

.. place your controls here, row 0 should be the menu options up top, row 1 is the middle section that will grow with the window size, and row 2 will be your bottom row that contains the Button controls.

Autres conseils

Doesn't has to be fixed width of first and last row, setting to "Auto" would adjust row heights to the height of the control inside that row. And the middle row height="*" would make it expand to available height.

<Grid>
  <Grid.RowDefinitions>
    <RowDefinition Height="Auto" />
    <RowDefinition Height="*" />
    <RowDefinition Height="Auto" />
  </Grid.RowDefinitions>
  <Button Grid.Row="0" />
  <Button Grid.Row="1" VerticalAlignment="Stretch" /> <!-- Will take available space -->
  <Button Grid.Row="2" />
</Grid>
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top