The WPF Toolkit DataGrid and Prism Regions

Mar 13, 2009 at 6:00 PM
I thought I'd cross-post an issue I've reported on the Prism codeplex site which can be found at:

I'm experiencing a column sizing issue when attempting to display a user control containing a WPF Toolkit DataGrid within a region. 

Given a DataGrid with several columns, one of which has a Width of "*" (to consume the remaining space of the constrained grid), the DataGrid is displaying fine when shown by statically declaring it within a Window, or by dynamically adding it to a Window's root Grid control.  However, the DataGrid does not appear to display correctly when displayed within a registered region.  When displayed within a region, the column assigned the width of "*" consumes slightly more than the remaining column space thus triggering a horizontal scroll bar.

After experiencing this in my own project, I took the DataGrid example available at and converted it to display the DataGrid in a region and saw the same resizing issues.

The only way I was able to correctly display the DataGrid was by putting the markup in a resource dictionary and adding the retrieved control that way.  Obviosuly this is a bit kludgy.

I can't say for sure whether the problem actually lies in the DataGrid or Prism's RegionManager code, but there definitely seems to be some issue using the two together.  Any ideas on what might be going on or how to overcome this?


Mar 26, 2009 at 11:07 PM
Here is the response I got from the Composite WPF thread:


Hi Derek,


We have been looking to reproduce your issue and you are right, this does happen. Having done some digging, we have not been able to determine the root cause yet, but we can tell you our believes based on our findings:

The WPF DataGrid appears to calculate its size once. Then, when the UI is updated, say you resize the window, it uses that previously established size to assign the new width/height to the columns and rows.

It appears that when loading the grid (placed in a view) into a region in the module initialize of your modules, the size that it will get is not yet determined, thus it miscalculates the width it should get. This makes the column assigned with the “*” width appear wider that it should.


Possible Workarounds:

·         Add the GridView to the region after the application has been loaded. (tested)

·         Load the module that has the grid on demand after the application has been loaded. (tested)

·         Check how to update the WPF GridView’s code to calculate the size of the Grid so it has the real size of the view.


Please let me know if this helps.


Damian Schenkelman