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

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?

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

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 *

they are auto generate from a item source

No more Ideas for this matter

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.