PRISM Composite app - DataGrid & [templates]

Topics: Prism v4 - WPF 4
Oct 18, 2012 at 11:29 AM
Edited Oct 18, 2012 at 4:50 PM



Firstly - would it be possible to have David Hill's template pack available from an MSDN location (or Codeplex).


Secondly; I've been trying to solve an issue I am having with a composite view that contains a datagrid. When I have this view incorporated via the view embedding features of PRISM the data grid vertical scroll bar auto activation does not work. I've tried the same procedure using a view with a datagrid  pachaged in a user control and it works fine. When the view is packaged as a prism view the data grid vertical bar does not get activated. Am I missing something in the view contruction?



Oct 18, 2012 at 8:33 PM

Hi Peter,

Based on my understanding the cause of this behavior could be that your DataGrid is being wrapped inside a StackPanel and the DataGrid's Height property has not a fixed value and as this panel will not limit the height of your control your vertical scroll bar will not be shown. This can be seen in any WPF application when defining a Datagrid inside a StackPanel.

A possible scenario where this could also happen, is if your region is defined in an ItemsControl which by default defines the panel to use for the layout of its items as a StackPanel. Hence in order to avoid this kind of problems you should have to replace your layout panel with a different panel which limits the height of it's children, or set a fixed value for your DataGrid control.

Also, in my experience this problem should not happen when defining regions in controls like a ContentControl or TabControl, as they do not use a StackPanel as their layout panel.

I hope you find this handy

Agustin Adami

Oct 19, 2012 at 1:21 PM


Thx @Agustin - that was exactly my problem. I have been following PRISM since its days as the composite application pattern and I had put together an app at that time. I must have been following an example because I was using an ItemsControl for the composite view that contained a DataGrid. When I changed this over to a contentControl all was fine. I don't remeber why I chose an ItemsControl (which is why I think I was following an example). I think originally I was percieving that the PRISM markup extensions only worked with ItemsControl markup and not [generally] witha ny control.

I have also come to the realization (because I ran into it also) that Grid row defintions with a height [for a row def] set to auto will also cause the content to take the space it requires and the [vertical] ScrollBar will not be activated, which I guess is in line with the auto defintion.