0

I have a grid with these column and row definitions

<Grid.ColumnDefinitions>
  <ColumnDefinition Width="Auto"
                    MinWidth="154" />
  <ColumnDefinition Width="Auto"
                    MinWidth="175" />
  <ColumnDefinition />
  <ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
  <RowDefinition Height="Auto" />
  <RowDefinition Height="Auto" />
  <RowDefinition Height="*" />
</Grid.RowDefinitions>

Inside the grid I have a Listview and it has a(gridview).

<ListView Grid.Column="0"
          Grid.Row="2"
          Name="ListView"
          ItemsSource="  {Binding MessageFields}"
          Margin="10,12,0,-5"
          Grid.ColumnSpan="3">
  <ListView.View>
    <GridView>
      <GridViewColumn Width="100">
        <GridViewColumnHeader Content="{StaticResource IdColumnContent}" />
      </GridViewColumn>
      <GridViewColumn Width="100">
        <GridViewColumnHeader Content="{StaticResource CodeColumnContent}" />

      </GridViewColumn>
      <GridViewColumn Width="Auto">
        <GridViewColumnHeader Content="{StaticResource NameColumnContent}" />

      </GridViewColumn>
      <GridViewColumn Width="100">
        <GridViewColumnHeader Content="{StaticResource PositionColumnContent}" />

      </GridViewColumn>
      <GridViewColumn Width="100">
        <GridViewColumnHeader Content="{StaticResource MappedListColumnContent}" />

      </GridViewColumn>
      <GridViewColumn>
        <GridViewColumnHeader Content="{StaticResource MappingRuleColumnContent}" />

      </GridViewColumn>
    </GridView>
  </ListView.View>

Inside the grid I also have a TreeView

   <TreeView 
   Grid.Column="3"  Grid.Row="2" ItemsSource="{Binding ,  Mode=TwoWay}">

When I maximize my window my treeview stays at its place but according to window resize. But my Listview it expands with the window but my last column stretches with the window and when I reduce/restore down the window size it shrinks . how can I make the grid and the tree to stretch appropriately on window resize?

Daniel
  • 10,864
  • 22
  • 84
  • 115
Ayda Sayed
  • 509
  • 2
  • 8
  • 21

1 Answers1

0

Basically, the last "column" in your GridView is filling the remaining space in your window? And it is not actually a column, but just empty space?

If that is the case, you should check out the answer for WPF : Extend last column of ListView's GridView

I would personally ditch the ListView/GridView, however, and use the DataGrid (if you are using .net 4 or greater).

Community
  • 1
  • 1
Abe Heidebrecht
  • 30,090
  • 7
  • 62
  • 66
  • yes the last column which is generated by the listview which i didn't create..it has no header but it takes space as a last column and thats the one that takes up space and stretching. DataGrid was working good for me but i changed it to listview for other requirement. – Ayda Sayed Jun 27 '13 at 13:41
  • 1
    Okay, well, the default behavior of the ListView is to fill the space with the header background. It isn't actually a column. And it doesn't support * size columns by default. That is why I pointed you to the answer of the other question. It shows 2 workarounds for the limitations of the GridView. – Abe Heidebrecht Jun 27 '13 at 14:16