tags:

views:

84

answers:

1

Hello, I have a WPF Line of business application. Most of it is hosted in user controls in tabs. I'm having an issue finding out how to layout this so it would fit any resolution (with scrolling if necessary). Here's the issue described in code because i really can't figure out how to put this to text, if it's not clear please let me know i'll try to draw something up.

<Grid>
  <Grid.RowDefinitions>
    <RowDefinition Height="Auto"/> 
    <RowDefinition Height="*"/>
  </Grid.RowDefinitions>
  <Grid.ColumnDefinitions>
    <ColumnDefinition Width="*"></ColumnDefinition> <!--What i actually want to say here isn't "take all remaining space" but "take all remaining space without scrolling, 
                                                    and then scroll based on everything as if this was auto and no longer *-->
    <ColumnDefinition Width="Auto"></ColumnDefinition><!--But what happens for now is that since this is auto , it will not scroll at all untill the * column has fully scrolled-->
  </Grid.ColumnDefinitions>
  <StackPanel>
    <StackPanel Orientation="Horizontal">
      <Label></Label>
      <TextBox></TextBox>
    </StackPanel>
  </StackPanel>
  <StackPanel Grid.Column="1">
    <StackPanel Orientation="Horizontal">
      <button> <!-- I want the button's container to be in an auto column , don't 
               want it to take size away from the fields unless needed but don't
               want it to stay visible at the expense of the fields either -->
    </StackPanel>
  </StackPanel>
  <TelerikGrid:RadGridView Grid.Row="1" Grid.ColumnSpan="2">
    <TelerikGrid:RadGridView.Columns>
      <TelerikGrid:GridViewDataColumn Width="*"/>  <!--  This makes my grid take a bajillon kilometers because it itself is in a Grid's column of * size itself in a scrollviewer -->
    </TelerikGrid:RadGridView.Columns>
  </TelerikGrid:RadGridView>
</Grid>
+1  A: 

Hard to tell given I cannot load your GridView control in a Window.

I recommend nesting a layout manager Grid for your controls inside your Grid to create a separation between your controls and the GridView. You also should consider combining all the controls in one StackPanel or other layout manager.

Regardless, this layout gives you separation between the controls and the GridView regardless of your choice of layout manager with no need to specify a column span.

<Grid> 
  <Grid.RowDefinitions> 
    <RowDefinition Height="Auto"/>  
    <RowDefinition Height="*"/> 
  </Grid.RowDefinitions> 
  <Grid.ColumnDefinitions> 
    <ColumnDefinition />
  </Grid.ColumnDefinitions> 

  <!-- Place a layout Grid inside your Grid to deal with controls -->
  <Grid Grid.Column="0" Grid.Row="0">
    <Grid.RowDefinitions>
       <RowDefinition/>
    </Grid.RowDefinitions>
    <Grid.ColumnDefinitions>
       <ColumnDefinition />
       <ColumnDefinition Width="Auto"/>
    </Grid.ColumnDefinitions>

    <!-- Removed your nested stack panel -->  
    <StackPanel Grid.Column="0" Grid.Row="0" Orientation="Horizontal"> 
      <Label></Label> 
      <TextBox></TextBox> 
    </StackPanel> 
    <StackPanel Grid.Column="1" Grid.Row="0" Orientation="Horizontal"> 
      <Button /> 
    </StackPanel> 
  </Grid>

  <!-- Add a spilter bar here  -->

  <!-- No need to span 2 columns anymore...  -->
  <TelerikGrid:RadGridView Grid.Column="0" Grid.Row="1" > 
    <TelerikGrid:RadGridView.Columns> 
      <TelerikGrid:GridViewDataColumn Width="*"/>  
    </TelerikGrid:RadGridView.Columns> 
  </TelerikGrid:RadGridView> 

  <!-- Add a status bar here -->

</Grid> 
Zamboni