Hi all,

I have a data grid that need to be with the same width of the windows that it is showing, but for some reason i can matain that width.
Can anybody give a hand here.

Best Regards

2 Years
Discussion Span
Last Post by maxpaine69

Not workin the datagrid forces the dockpanel to get the width of the table


After adding a datagrid to the dockpanel add the following in your XAML for your datagrid.

Height="{Binding RelativeSource={RelativeSource AncestorType={x:Type Window}}, Path=ActualHeight}"

This will force your datagrid to maintain the host window's height.

The width seems to be handeled correctly by the dock panel.

your Main component on the screen should not be the default grid change this to a dockpanel and set the property LastChildFill to true and drop your datagrid onto this dockpanel.

<DockPanel LastChildFill="True">

Are you Auto Generating the Columns from the ItemSource?

Edited by Fenrir()


still when populated its not working, it seems the problem its inside the datagrid wwhen it get the headers.

Edited by maxpaine69


Could you please post your code that populates the grid. Are you manually defining the columns on the grid? or are they auto generated by the item source. If they are manual you need to remove the auto size property and set it to *

Edited by Fenrir()

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.