I'm using the XamDataGrid with the Composite Application Guidance for WPF (Prism). The problem that I am having is that when I put the XamDataGrid into a view or on the window, it's extending outside the bounds of the view area, and I can't figure out why. I can see the top of the vertical scroll bar, but the horizontal scroll bar is out of the view area and the bottom button on the vertical scroll bar is hidden.
Here's a screenshot of what's happening (there are 100 items in the grid).
Here's the XAML for my top-level window:
<
Window x:Class="Mvs.FieldAudit.WindowsClient.Shell.ShellWindow"
xmlns="">schemas.microsoft.com/.../presentation"
xmlns:x="">schemas.microsoft.com/.../xaml"
xmlns:cal="">www.codeplex.com/CompositeWPF"
xmlns:mvs="xxx"
Title="xxx"
Left="{Binding Path=Left}" Top="{Binding Path=Top}"
Width="{Binding Path=Width}" Height="{Binding Path=Height}"
WindowState="{Binding Path=WindowState}" ResizeMode="CanResizeWithGrip">
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<ItemsControl Name="MainRegion" cal:RegionManager.RegionName="{x:Static mvs:ShellRegions.MainRegion}" Grid.Row="0" />
<StatusBar Name="StatusBarRegion" cal:RegionManager.RegionName="{x:Static mvs:ShellRegions.StatusBarRegion}" Grid.Row="1" VerticalAlignment="Bottom">
<TextBlock>Ready</TextBlock>
</StatusBar></Grid>
</
Window>
Inside of this, I have a top-level view for my module that was built using a DataTemplate (all of my views are DataTemplates):
<DataTemplate DataType="{x:Type xxx:xxxPresentationModel}">
<RowDefinition Height="104"/>
<Image Source="pack://application:,,,/xxx;Component/xxx.png" Stretch="None" HorizontalAlignment="Left" VerticalAlignment="Top" Grid.Row="0"/>
<ItemsControl ItemsSource="{Binding Path=MainRegion.Views}" Grid.Row="1"/>
</Grid></DataTemplate>
Finally, here's the embedded DataTemplate with the XamDataGrid:
<igDP:XamDataGrid DataSource="{Binding Path=Cases}" Grid.Row="2">
<igDP:XamDataGrid.FieldLayouts>
<igDP:FieldLayout>
<igDP:FieldLayout.Fields>
<igDP:Field Name="AccountName" Label="Account Name"/>
</igDP:FieldLayout.Fields>
</igDP:FieldLayout>
</igDP:XamDataGrid.FieldLayouts>
</igDP:XamDataGrid>
<ItemsControl Grid.Row="0">
<Button>Button 1</Button>
</ItemsControl>
<WrapPanel Grid.Row="1">
<Label>Label 1</Label>
<TextBox></TextBox>
</WrapPanel>
Can anyone tell me what I might be doing wrong or how to get the XamDataGrid to be sized correctly for the window?
Thanks.
Michael
Nope. You were exactly right. This is my first Prism app and I was following the examples in the online help guides. It never even occurred to me that ItemPanel was using a StackPanel for layout. When I changed the layout template to a Grid instead, it worked. Will have to go back and review how I'm building the UI.
Thank you very much for the help.
Maybe I'm misreading your xaml but you have several controls (or even just 1) that are being put into an ItemsControl (MainRegion). The default ItemPanel for an ItemsControl is a StackPanel. A stackpanel with an orientation of Vertical (which is the default orientation) arranges its children using its arranged width and an infinite height - i.e. the children have a height based on the size of their content. If you used a ListBox instead of the DataGrid you would have the same behavior because the elements are being measured with an infinite height to find out their desired size. Maybe you want to assign a MaxHeight of the grid, set the itemcontrol's VerticalScrollBarVisibility to Auto so you can scroll that list of controls, or perhaps use other panels to arrange the controls in the body of your window.
Hi Nathalie.
I don't understand your response. Did you fix the issue? How?
Hi,
I had the same problem in horizontal .
I had autoFit = false and the MAXWidth (or Height) with a value.
For Me it's Ok :)
Nathalie