0
votes

I'm having a bit of a hassle making my controls stretch in WPF so hopefully someone will know the answer. Basically I have a 4 row grid, with rows defined as follows:

<Grid.RowDefinitions>
     <RowDefinition Height="10*"/>
     <RowDefinition Height="60*" />
     <RowDefinition Height="15*" />
     <RowDefinition Height="15*" />
</Grid.RowDefinitions>

It is the 2nd row I am interested in, because within there is a tree view (column 0) and a list view (column 1). All I want to happen is for the two objects to expand to fill the available space - in this case 60% but no matter what I do I can't get it to expand.

My code for the row in question is as follows:

<Grid Grid.Row="1">

  <UniformGrid VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Height="Auto">

      <TreeView x:Name="treeSubProjects"         
                SelectedItemChanged="treeSubProjects_SelectedItemChanged" 
                VerticalAlignment="Stretch" HorizontalAlignment="Stretch">

          <TreeView.ItemTemplate>

              <HierarchicalDataTemplate DataType="{x:Type local:Project}" ItemsSource="{Binding Path=children}">
                  <TextBlock x:Name="txtSubProject" Text="{Binding Path=ProjectName}" />

              </HierarchicalDataTemplate>
         </TreeView.ItemTemplate>

     </TreeView>
     <ListBox x:Name="lstDetails"  VerticalAlignment="Stretch" HorizontalAlignment="Stretch"/>

 </UniformGrid>          

</Grid>

I decided on the UniformGrid after reading some advice here, but prior to that I had a 2 column grid containing the controls. Nothing I select seems to make any difference - the controls are compressed at the top of the screen and not taking up 60% as expected

Any advice appreicated

1

1 Answers

3
votes

Add Rows="1" Columns="2" to your UniformGrid and remove Height=...