Click here to Skip to main content
15,066,084 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.
HTML
<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">
                    &lt;Label Content="Measured" HorizontalAlignment="Center" Foreground="Black"&gt;&lt;/Label&gt;
                </border>
                <border grid.column="5" grid.columnspan="3" borderbrush="Black" horizontalalignment="Stretch" borderthickness="1">
                    &lt;Label Content="Reference" HorizontalAlignment="Center" Foreground="Black"&gt;&lt;/Label&gt;
                </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"&gt;
                <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
>
Posted
Updated 27-Nov-13 22:10pm
v4
Comments
SunnyGaur 28-Nov-13 21:49pm
   
Somebody please reply.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900