Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
145
XamDataGrid scrolls out of the viewable area of the window
posted

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}">

<Grid>

<Grid.RowDefinitions>

<RowDefinition Height="104"/>

<RowDefinition/>

</Grid.RowDefinitions>

<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:

<DataTemplate DataType="{x:Type xxx:xxxPresentationModel}">

<Grid>

<Grid.RowDefinitions>

<RowDefinition Height="Auto"/>

<RowDefinition Height="Auto"/>

<RowDefinition/>

</Grid.RowDefinitions>

<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>

</Grid></DataTemplate>

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

Parents
  • 54937
    Verified Answer
    Offline posted

    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.

Reply Children
No Data