<igDock:XamDockManager> <igDock:XamDockManager.Panes> <igDock:SplitPane> <igDock:ContentPane> <StackPanel Height="300"> <Button>MyButton</Button> <igData:XamDataPresenter>
I have a situation similar to the above where I have a Button and a XamDataPresenter together on a dockable pane. However, with this arrangement, if the records displayed in the XamDataPresenter are more than the height of the pane, no vertical scroll bar appears on the right of the XamDataPresenter. I figured to use a Grid instead of a StackPanel to fix this from here: http://karlshifflett.wordpress.com/category/uncategorized/
But this presents a couple of problems. 1) The Button disappears, and 2) if I undock the pane and make it vertically bigger, the XamDataPresenter doesn't stretch to fill the size of the pane. If I remove the Height attribute from the Grid, its height becomes as big as required to display all records and the pane matches that size even when initially docked, thus resulting in the pane exceeding the size of the browser window and/or screen.
Is it possible to use a StackPanel without the vertical scroll bar disappearing? And in either case, how can I ensure the XamDataPresenter always stretches to the size of the pane but setting the pane to a maximum initial size (so it doesn't stretch to an excessive size just to match the XamDataPresenter displaying all records)?
Many thanks,Jason
When you set an explicit Height on an element, that is what WPF will use for the height of the element regardless of what a parent element will/could position it as. So regardless of the size of the containing ContentPane, your panel will always be 300. With regards to using a StackPanel, it is the design of a stack panel that when it measures & arranges its children it always measures them with an infinite value in the orientation (so if the orientation is vertical then when it measures its children it measures them with an infinite height). So an element measured with an infinite height is going to return whatever size is needed to show its content. This isn't specific to xamDataGrid - it would happen with any element.
Now with regards to the xamDockManager, if you have a root SplitPane that is docked and you do not specify a constraining value based on the docked placement (e.g. if its docked top/bottom and you don't set a Height) then the SplitPane will use as much space as its measured with to measure its children. If its content is a listbox with lots of items then that control will ultimately return a value indicating that it can use all the space.
I think ultimately what you want is a Grid element that has 2 row definitions - one with Auto for the button and one with a size of * (i.e. get the remaining space). To constrain the height of the xamDataGrid (or any list control, etc. with large content) you can either set something like the MaxHeight or you can use an approach like one I outlined here.
Thanks Alex. I figured the problem with the button disappearing would be easily resolvable by setting Heights explicitly. Thanks for your help with that.
But, the main problem is if I undock the pane and make it vertically bigger, the XamDataPresenter doesn't stretch to fill the size of the pane while Grid Height="300". If I remove this Height attribute from the Grid, the XamDataPresenter stretches as big as required to display all records and the pane matches that size even when initially docked, thus resulting in the pane exceeding the size of the browser window and/or screen upon start-up.
So, I need to find a way to ensure that the XamDataPresenter always stretches to the size of the pane but set the pane to a maximum initial size (such as "300" so it doesn't stretch to an excessive size just to match the XamDataPresenter displaying all records).
Any ideas much appreciated on this.
Thanks,
Jason
Hello Jason,
On a quick view I solved some of the problems with the grid -- if you define RowDefinitions of the grid the button will not disappear and there will be a scrollbar visible like this:
<Grid Height="300"> <Grid.RowDefinitions> <RowDefinition Height="*"/> <RowDefinition Height="5*"/> </Grid.RowDefinitions> <Button Grid.Row="0">MyButton</Button> <igDP:XamDataPresenter Grid.Row="1" Name="presenter" /> </Grid>
but I am not sure why XamDockManager's behavior is strange with the StackPanel.
Alex.