This project is read-only.

[Version 2.0] DataGrid in Floating Window Issue

May 15, 2013 at 5:13 PM
Hi there,

has anyone ever tried to put a DataGrid into a Floating Window and make that DataGrid stretch horizontally? Try it in a really low level example. Just a DataGrid (standard, no additional styles) inside a usercontrol inside a Floating Window. ColumnWidth set to "*", AutoGenerateColumns to "true" and that's it.
When you do this inside a regular WPF Window or even an ElementHost, the DataGrid (and the contained columns, of course) always stretches over all the available width as you resize (or maximize/restore) the parent window. Same behavior when the DataGrid is docked into Avalon Dock.
But as soon as you have the DataGrid inside a Floating Window, resizing does not work as expected any more. Just change the width a little bit back and forth and sooner or later an empty column will appear on the right side of the DataGrid (even though the columns actually DO rearrange in some way). The DataGrid still uses all the available space, but the columns don't. Especially if you maximize the Floating Window, the columns don't react at all. Same thing, when you enhance the height of the Floating Window until the vertical scrollbar disappears: the columns won't adjust their widths.

This looks like a bug in the DataGrid control to me which I can only reproduce inside the Floating Window of Avalon Dock 2. Maybe it has something to do with the HwndHost? Maybe some message is not tunneled through the visual tree correctly? I've been searching the Internet for 2 days now and did not find the slightest idea of a solution so far... Why does the DataGrid itself behave correctly while the Columns (or probably DataGridCells/DataGridRows) do not use all the space which is obviously known to the parent DataGrid control?!?

I'd really like to use Avalon Dock in my current project but the described layout issue really is kind of a show stopper...