Help in my WPF layout

I have a WPF business application. Most of them are placed in user tabbed controls. I had a problem finding the layout so that it matches any resolution (scrolling if necessary). Here the problem is described in the code, because I really cannot understand how to put this in the text, if it is not clear, please let me know, I will try to draw something.

<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 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 column of * size itself in a scrollviewer -->
    </TelerikGrid:RadGridView.Columns>
  </TelerikGrid:RadGridView>
</Grid>
+3
source share
1 answer

It is hard to say that I cannot load the GridView control in a window.

Grid , GridView. StackPanel .

, GridView, , .

<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> 
+1

Source: https://habr.com/ru/post/1760969/


All Articles