0

I'm using this XAML:

    <Border x:Name="border1" Grid.Row="1">
        <toolkit:HeaderedContentControl Header="HeaderedContentControl" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" MaxWidth="{Binding ActualWidth, ElementName=border1}" MaxHeight="{Binding ActualHeight, ElementName=border1}">
            <Grid HorizontalAlignment="Left">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition/>
                    <ColumnDefinition Width="Auto"/>
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition/>
                    <RowDefinition Height="32"/>
                </Grid.RowDefinitions>
                <ScrollViewer Grid.ColumnSpan="2" Margin="0" MinHeight="75" d:LayoutOverrides="Width, Height" ScrollViewer.VerticalScrollBarVisibility="Auto" Padding="0" ScrollViewer.HorizontalScrollBarVisibility="Auto" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch">
                    <sdk:DataGrid ItemsSource="{Binding ItemSummaries}">
                    </sdk:DataGrid>
                </ScrollViewer>
                <Button res:Strings.Assignment="Content=ItemsView.SaveButtonText" Grid.Row="1" Margin="5" Command="{Binding SaveCommand}" Grid.Column="1" d:LayoutOverrides="GridBox"/>
            </Grid>
        </toolkit:HeaderedContentControl>
    </Border>

My goal is to keep the HeaderedContentControl from exceeding its containing Border, which I've done, but once the DataGrid exceeds its alotted space, I want it to start scrolling. I've tried this with ever combination with or without a parent ScrollViewer the Grid pushes beyond the bounds of the HeaderedContentControl and no scroll bars appear. What on earth am I doing wrong here?

Jordan
  • 9,642
  • 10
  • 71
  • 141
  • Try updating `HeaderedContentControl`'s template to use a `Grid` and see if that helps. http://stackoverflow.com/questions/5066450/wpf-how-to-make-headeredcontentcontrol-content-fit-height/5066955#5066955 – decyclone Jun 21 '12 at 18:26
  • That fixed it. I always wondered why the HeaderedContentControl gave me such a headache. A StackPanel, really? Well, this works and I'll be using it in all of my projects. Add this as an answer and I'll accept. – Jordan Jun 21 '12 at 18:41

1 Answers1

3

The answer above given by decyclone worked. Basically, I added the following to my resource dictionary to change all instances of HeaderedContentControl to use a Grid instead of the default StackPanel:

<ControlTemplate TargetType="HeaderedContentControl">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <ContentControl Content="{TemplateBinding Header}" Grid.Row="0" />
        <ContentControl Content="{TemplateBinding Content}" Grid.Row="1" />
    </Grid>
</ControlTemplate>

This was the code found on the link given above.

Community
  • 1
  • 1
Jordan
  • 9,642
  • 10
  • 71
  • 141
  • Working with `StackPanel`s has always been painful for me. I always try to avoid using a `StackPanel` in my application's layouts. Glad to see it worked for you as well. – decyclone Jun 22 '12 at 17:01