Hi,
I am using a Datagrid. The grid initially has 7 rows. Dynamically when I add more rows datagrid behaves normally and adds scroll bar if rows grow beyond the specified size.
I increase the size of window the grid expands and now when I try to reduce the size of window the problem occurs. The datagrid shrinks only until all the rows are visible.
Ideally if I try to reduce the size of window, datagrid size should decrease and the scrollbar should appear, but this is not happening.
Below is the code. Datagrid is inside a grid which is futher in a grid and this page is viewed in a frame on some other window.
Please suggest.
<pre> <grid grid.row="2" grid.column="0" margin="0,3,3,0" name="gridLogTableHolder" sizechanged="gridLogTableHolder_SizeChanged">
<grid.rowdefinitions>
<rowdefinition height="auto" />
<rowdefinition height="2*" />
</grid.rowdefinitions>
<grid grid.row="0" removed="White">
<grid.columndefinitions>
<columndefinition width="{Binding ElementName=colColor, Path=ActualWidth}" />
<columndefinition width="{Binding ElementName=colMx, Path=ActualWidth}" />
<columndefinition width="{Binding ElementName=colMy, Path=ActualWidth}" />
<columndefinition width="{Binding ElementName=colML, Path=ActualWidth}" />
<columndefinition width="{Binding ElementName=colMDE, Path=ActualWidth}" />
<columndefinition width="{Binding ElementName=colRx, Path=ActualWidth}" />
<columndefinition width="{Binding ElementName=colRy, Path=ActualWidth}" />
<columndefinition width="{Binding ElementName=colRL, Path=ActualWidth}" />
</grid.columndefinitions>
<border grid.column="1" grid.columnspan="4" borderbrush="Black" horizontalalignment="Stretch" borderthickness="1">
<Label Content="Measured" HorizontalAlignment="Center" Foreground="Black"></Label>
</border>
<border grid.column="5" grid.columnspan="3" borderbrush="Black" horizontalalignment="Stretch" borderthickness="1">
<Label Content="Reference" HorizontalAlignment="Center" Foreground="Black"></Label>
</border>
</grid>
<datagrid grid.row="1" autogeneratecolumns="False" horizontalalignment="Stretch" verticalalignment="Stretch" name="logTableGrid" headersvisibility="All">
HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" MouseDoubleClick="gridElement_MouseDoubleClick" AlternatingRowBackground="AliceBlue" Rowremoved="White" IsReadOnly="True">
<datagrid.columns>
<datagridtextcolumn header="Color" binding="{Binding Key}" x:name="colColor" width="*" canusersort="False" xmlns:x="#unknown"></datagridtextcolumn>
<datagridtextcolumn header="x" binding="{Binding Measuredx,StringFormat={}{0:n3}}" x:name="colMx" width="*" canusersort="False" xmlns:x="#unknown"></datagridtextcolumn>
<datagridtextcolumn header="y" binding="{Binding Measuredy,StringFormat={}{0:n3}}" x:name="colMy" width="*" canusersort="False" xmlns:x="#unknown"></datagridtextcolumn>
<datagridtextcolumn header="L" binding="{Binding MeasuredL,StringFormat={}{0:n3}}" x:name="colML" width="*" canusersort="False" xmlns:x="#unknown"></datagridtextcolumn>
<datagridtextcolumn header="DeltaE" binding="{Binding MeasuredDeltaE,StringFormat={}{0:n3}}" x:name="colMDE" width="*" canusersort="False" xmlns:x="#unknown"></datagridtextcolumn>
<datagridtextcolumn header="x" binding="{Binding Referencex,StringFormat={}{0:n3}}" x:name="colRx" width="*" canusersort="False" xmlns:x="#unknown"></datagridtextcolumn>
<datagridtextcolumn header="y" binding="{Binding Referencey,StringFormat={}{0:n3}}" x:name="colRy" width="*" canusersort="False" xmlns:x="#unknown"></datagridtextcolumn>
<datagridtextcolumn header="L" binding="{Binding ReferenceL,StringFormat={}{0:n3}}" x:name="colRL" width="*" canusersort="False" xmlns:x="#unknown"></datagridtextcolumn>
</datagrid.columns>
</datagrid>
</grid
>