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

Recommended Answers

Try adding it to a dock Panel Click Here

Jump to Post

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 …

Jump to Post

All 7 Replies

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 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.