Below I have inserted a screen shot - I'm not sure how well you can see it, but you should be able to understand the question.
It is a grid with a couple of groupings and in the groupings are summaries. To show the summaries, the grid makes the grouped row a lot bigger (the dark blue area in my row). I do not want the row to get any bigger, I would rather the row stay the same size because I only want to show 1 summary. In the screen shot below, I have drawn a red line where I would like the summary to show up (the light blue area of my row) so that the group row does not get any bigger than a standard row. Is this possible?
Summary values are displayed in one of two ways depending upon the value of the FieldLayoutSettings.GroupBySummaryDisplayMode - included as part of the group by record's description (Text) or aligned to the cells in a row below the group by's description (SummaryCellsAlwaysBelowDescription). You may submit a suggestion for adding another option that will try to display the summary cells in the same row as the group by record's description assuming the summary cell wouldn't overlap the description. If you know for sure that the cell being summarized won't overlap then you could retemplate the GroupByRecordPresenter and rearrange the GroupBySummariesPresenter element within the template with respect to the ContentControl that is bound to the Description property of the record presenter.
Is there a way to make the dark blue area where the summaries are smaller? Change the height? Is there a way to customize it at all?
Yes as I mentioned you can retemplate the GroupByRecordPresenter. The default xaml is included with the product in the DefaultStyles directory.
I do not see anything related to the DataGrid in the default styles directory. Could you direct me specifically to the file that contains the default xaml or paste the default xaml in your response?
Thanks.
There is a DataPresenter subfolder under DefaultStyles that has a DataPresenterGeneric_Express.xaml file which has the default style/template for the GroupByRecordPresenter.
Re-templating the GroupByRecordPresenter seems like a lot simply to change a height property. I took a look at the default xaml and I'm not even sure how to go about either changing the height or moving the location of the summary labels. While I would rather do it right in the xaml, is there an easier way to do it programatically?
In WPF the size, position, etc. of elements is based on the templates so in order to change the look quite often you need to change the template. There are no hard coded heights set. The size of the elements are based on their contents and their positioning is based on the template. The template is set up such that the GroupBySummariesPresenter is below the description because otherwise the description text might overlap the summaries of the cells.
Assuming you want to keep the arrangement of the summary cells below the description then you would probably look for padding/margins/borderthickness that have top/bottom values to try and remove some of the extra space that might be present within the element and its descendants. You can use a tool like Snoop to try and play around with the template in the running app to understand what is providing the spacing. In this case it looks like the SummaryRecordContentArea & SummaryRecordCellArea contain a Border whose BorderThickness is 0,1,0,1 (i.e 1 pixel on top and 1 on the bottom). Retemplating those elements (based on the styles in the DefaultStyles) such that they don't have those BorderThickness gets you back 4 pixels in the height of groupbyrecord.
Hi Andrew.
I am trying to do exactly the same thing, so far I have had marginal success by adding negative bottom margins to GroupByRecordPresenter
Now there is an issue with collapsed groups. Collapsing the summary group will also collapse its records - including the SummaryRecordPresenter.
I tried another approach, where I retemplated the GroupByRecordPresenter so that it included a SummaryRecordPresenter but I couldn't manage to get the SummaryRecordPresenter to display anything (even using reflection to call InitialiseRecord) .
I am really at wit's end here. Another option is to override the GroupByRecordPresenter's Expander command and manually alter the VisibleRecordsCollection but this then conflicts with filtering and aggregation.
I would be very grateful for some help!
All I want is a single row for both summary and group by expander. I don't even care about the group by label
Future people: Here is how to solve this - edit the template for the GroupByRecordPresenter and use a grid rather than a stackpanel for the label / summary. You might get overlap, but I am willing to live with this.
Here is the custom style I use :
<!-- _________________________ GroupByRecordPresenter ______________________________________ --> <Style TargetType="{x:Type igDP:GroupByRecordPresenter}"> <Setter Property="Foreground" Value="{DynamicResource {ComponentResourceKey {x:Type igDP:XamDataGrid}, LabelForeground}}" /> <Setter Property="Background" Value="#00FFFFFF" /> <Setter Property="Margin" Value="0,0,0,2" /> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type igDP:GroupByRecordPresenter}"> <ControlTemplate.Resources> <Storyboard x:Key="sbDisplayNested"> <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="ncpVisual" Storyboard.TargetProperty="Opacity" FillBehavior="HoldEnd"> <DiscreteDoubleKeyFrame Value="0" KeyTime="00:00:00" /> <DiscreteDoubleKeyFrame Value="0" KeyTime="00:00:00.25" /> <SplineDoubleKeyFrame KeySpline="0.5,0.5,0.5,0.5" Value="1" KeyTime="00:00:0.75" /> </DoubleAnimationUsingKeyFrames> <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="ncpVisual" Storyboard.TargetProperty="(UIElement.Visibility)"> <DiscreteObjectKeyFrame Value="{x:Static Visibility.Visible}" KeyTime="00:00:00" /> <DiscreteObjectKeyFrame Value="{x:Static Visibility.Collapsed}" KeyTime="00:00:0.75" /> </ObjectAnimationUsingKeyFrames> <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="ncpMask" Storyboard.TargetProperty="(UIElement.Visibility)"> <DiscreteObjectKeyFrame Value="{x:Static Visibility.Visible}" KeyTime="00:00:00" /> <DiscreteObjectKeyFrame Value="{x:Static Visibility.Collapsed}" KeyTime="00:00:0.75" /> </ObjectAnimationUsingKeyFrames> </Storyboard> <Storyboard x:Key="sbHideNested"> <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="NestedContentPresenter" Storyboard.TargetProperty="Opacity" FillBehavior="HoldEnd"> <SplineDoubleKeyFrame KeySpline="0.5,0.5,0.5,0.5" Value="1" KeyTime="00:00:00.15" /> </DoubleAnimationUsingKeyFrames> </Storyboard> </ControlTemplate.Resources> <Grid Background="{TemplateBinding Background}"> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto" /> <ColumnDefinition Width="*" /> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition x:Name="row0" Height="Auto" /> <RowDefinition x:Name="row1" Height="Auto" /> <RowDefinition x:Name="row2" Height="*" /> </Grid.RowDefinitions> <!-- Row for nested content --> <!-- Expansion Checkbox --> <!-- AS 1/27/09 NA 2009 Vol 1 - Set ZIndex and RenderTransform for fixed fields --> <!-- AS 6/3/09 NA 2009 Vol 2 - Added Command(Parameter) & ToggleMode to support undo/redo --> <igwindows:ExpansionIndicator x:Name="ExpansionIndicator" RenderTransform="{TemplateBinding FixedNearElementTransform}" Panel.ZIndex="1" Grid.Row="1" Visibility="{TemplateBinding ExpansionIndicatorVisibility}" Command="{x:Static igDP:DataPresenterCommands.ToggleRecordIsExpanded}" CommandParameter="{TemplateBinding Record}" ToggleMode="Manual" IsChecked="{Binding Path=IsExpanded, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" /> <!-- JJD 6/4/09 - TFS17060 - Added Header site to support HeaderPlacementInGroupBy 'OnTop' in reporting --> <ContentPresenter x:Name="PART_HeaderContentSite" Grid.Row="0" Grid.Column="1" Content="{TemplateBinding HeaderContent}" Visibility="{Binding Path=HasHeaderContent, Converter={StaticResource BoolToVisConverter}, RelativeSource={RelativeSource TemplatedParent}}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" d:IsHidden="True" /> <!-- Record content site --> <!-- AS 1/27/09 NA 2009 Vol 1 - Set RenderTransform for fixed fields --> <Grid x:Name="PART_RecordContentSite" RenderTransform="{TemplateBinding FixedNearElementTransform}" Margin="0" Grid.Row="1" Grid.Column="1" Visibility="Collapsed"> <!-- Background Bar --> <Border HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="Auto" Height="Auto" RenderTransformOrigin="0.5,0.5" CornerRadius="2,2,2,2" SnapsToDevicePixels="True" Background="{DynamicResource {ComponentResourceKey {x:Type igDP:XamDataGrid}, LabelBackground}}"> <Grid Margin="0,0,0,0" Width="Auto" Height="Auto"> <Rectangle Stroke="#44000000" StrokeThickness="1" RadiusX="1.55015910897703" RadiusY="1.55015910897703" Fill="Transparent" /> <Rectangle Margin="1" Stroke="#44FFFFFF" StrokeThickness="1" RadiusX="0.550159108977027" RadiusY="0.550159108977027" Fill="Transparent" /> </Grid> </Border> <!-- End Added 8/1/2006 GH --> <!-- End Background Bar --> <Border x:Name="highlight" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="Auto" Height="Auto" CornerRadius="2,2,2,2" Background="{DynamicResource {ComponentResourceKey {x:Type igDP:XamDataGrid}, LabelHighlight}}"> <Grid Margin="0,0,0,0" Width="Auto" Height="Auto"> <Rectangle Stroke="#44000000" StrokeThickness="1" RadiusX="1.55015910897703" RadiusY="1.55015910897703" Fill="Transparent" /> <Rectangle Margin="1" Stroke="#44FFFFFF" StrokeThickness="1" RadiusX="0.550159108977027" RadiusY="0.550159108977027" Fill="Transparent" /> </Grid> </Border> <!-- End Add 8/1/2006 GH--> <!-- Label Text --> <!-- SSP 4/3/08 - Summaries Functionality Enclosed the existing ContentControl node into a Grid and added GroupBySummariesPresenter node. --> <Grid> <ContentControl Style="{StaticResource LabelContentStyle}" Content="{Binding Path=Description, RelativeSource={RelativeSource TemplatedParent}}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" /> <!-- SSP 4/3/08 - Summaries Functionality --> <!-- AS 1/27/09 NA 2009 Vol 1 - Set RenderTransform for fixed fields --> <igDP:GroupBySummariesPresenter RenderTransform="{TemplateBinding ScrollableElementTransform}" HorizontalAlignment="Left" x:Name="GroupBySummariesPresenter" Visibility="Collapsed" GroupByRecord="{TemplateBinding Record}" /> </Grid> </Grid> <!-- Nested Content --> <Grid x:Name="PART_NestedContentSite" Grid.Row="2" Grid.Column="1" Visibility="Collapsed"> <!-- AS 2/13/09 TFS13978 - Set RenderTransform for fixed fields --> <Border CornerRadius="0,0,3,3" BorderBrush="#44102975" BorderThickness="1" RenderTransform="{TemplateBinding FixedNearElementTransform}"> <Border.Background> <LinearGradientBrush StartPoint="0,0" EndPoint="0,1"> <GradientStop Color="#FFFFFFFF" Offset="0.25" /> <GradientStop Color="#FFEEEEEE" Offset="1.2" /> </LinearGradientBrush> </Border.Background> <!-- AS 3/25/09 TFS15801 --> <ContentControl RenderTransform="{TemplateBinding ScrollableElementTransform}" x:Name="NestedContentPresenter" Content="{Binding Path=NestedContent, RelativeSource={RelativeSource TemplatedParent}}" Margin="0,0,0,5" /> </Border> <!-- AS 11/14/07 BR26035 The namescope was broken because the recordlistcontrol was not in the logical tree. We need to use a ContentControl instead so the content is made a logical child. --> <!-- AS 3/25/09 TFS15801 This should be nested within the Border above. <ContentControl x:Name="NestedContentPresenter" Content="{Binding Path=NestedContent, RelativeSource={RelativeSource TemplatedParent}}" Margin="0,0,0,5"/>--> </Grid> </Grid> <ControlTemplate.Triggers> <Trigger Property="ShouldDisplayGroupByRecordContent" Value="true"> <Setter TargetName="PART_RecordContentSite" Property="Visibility" Value="Visible" /> </Trigger> <Trigger Property="ShouldDisplayGroupByRecordContent" Value="false"> <Setter TargetName="ExpansionIndicator" Property="Visibility" Value="Hidden" /> </Trigger> <!-- SSP 4/3/08 - Summaries Functionality --> <Trigger Property="ShouldDisplaySummaryCells" Value="true"> <Setter TargetName="GroupBySummariesPresenter" Property="Visibility" Value="Visible" /> </Trigger> <MultiTrigger> <MultiTrigger.Conditions> <Condition Property="Orientation" Value="Vertical" /> <Condition Property="ShouldDisplayGroupByRecordContent" Value="false" /> </MultiTrigger.Conditions> <Setter TargetName="ExpansionIndicator" Property="Grid.Row" Value="2" /> </MultiTrigger> <!-- JJD 1/20/09 - In horizontal mode we need to leave the height on the content area visible --> <MultiTrigger> <MultiTrigger.Conditions> <Condition Property="Orientation" Value="Horizontal" /> <Condition Property="ShouldDisplayGroupByRecordContent" Value="false" /> </MultiTrigger.Conditions> <Setter TargetName="PART_RecordContentSite" Property="Visibility" Value="Visible" /> </MultiTrigger> <Trigger Property="HasNestedContent" Value="true"> <Setter TargetName="PART_NestedContentSite" Property="Visibility" Value="Visible" /> </Trigger> <!-- MD 6/10/10 - ChildRecordsDisplayOrder feature--> <MultiDataTrigger> <MultiDataTrigger.Conditions> <Condition Binding="{Binding Path=FieldLayout.ChildRecordsDisplayOrderResolved}" Value="BeforeParent" /> <Condition Binding="{Binding Path=Orientation, RelativeSource={RelativeSource Self}}" Value="Vertical" /> </MultiDataTrigger.Conditions> <Setter TargetName="PART_NestedContentSite" Property="Grid.Row" Value="0" /> <Setter TargetName="PART_HeaderContentSite" Property="Grid.Row" Value="1" /> <Setter TargetName="ExpansionIndicator" Property="Grid.Row" Value="2" /> <Setter TargetName="PART_RecordContentSite" Property="Grid.Row" Value="2" /> <Setter TargetName="row0" Property="Height" Value="*" /> <Setter TargetName="row2" Property="Height" Value="Auto" /> </MultiDataTrigger> <!-- MD 8/3/10 - TFS35609 --> <MultiDataTrigger> <MultiDataTrigger.Conditions> <Condition Binding="{Binding Path=FieldLayout.ChildRecordsDisplayOrderResolved}" Value="BeforeParentHeadersAttached" /> <Condition Binding="{Binding Path=Orientation, RelativeSource={RelativeSource Self}}" Value="Vertical" /> </MultiDataTrigger.Conditions> <Setter TargetName="PART_NestedContentSite" Property="Grid.Row" Value="0" /> <Setter TargetName="PART_HeaderContentSite" Property="Grid.Row" Value="1" /> <Setter TargetName="ExpansionIndicator" Property="Grid.Row" Value="2" /> <Setter TargetName="PART_RecordContentSite" Property="Grid.Row" Value="2" /> <Setter TargetName="row0" Property="Height" Value="*" /> <Setter TargetName="row2" Property="Height" Value="Auto" /> </MultiDataTrigger> </ControlTemplate.Triggers> </ControlTemplate> </Setter.Value> </Setter> <Setter Property="TemplateCardView"> <Setter.Value> <ControlTemplate TargetType="{x:Type igDP:GroupByRecordPresenter}"> <ControlTemplate.Resources> <Storyboard x:Key="sbDisplayNested"> <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="ncpVisual" Storyboard.TargetProperty="Opacity" FillBehavior="HoldEnd"> <DiscreteDoubleKeyFrame Value="0" KeyTime="00:00:00" /> <DiscreteDoubleKeyFrame Value="0" KeyTime="00:00:00.25" /> <SplineDoubleKeyFrame KeySpline="0.5,0.5,0.5,0.5" Value="1" KeyTime="00:00:0.75" /> </DoubleAnimationUsingKeyFrames> <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="ncpVisual" Storyboard.TargetProperty="(UIElement.Visibility)"> <DiscreteObjectKeyFrame Value="{x:Static Visibility.Visible}" KeyTime="00:00:00" /> <DiscreteObjectKeyFrame Value="{x:Static Visibility.Collapsed}" KeyTime="00:00:0.75" /> </ObjectAnimationUsingKeyFrames> <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="ncpMask" Storyboard.TargetProperty="(UIElement.Visibility)"> <DiscreteObjectKeyFrame Value="{x:Static Visibility.Visible}" KeyTime="00:00:00" /> <DiscreteObjectKeyFrame Value="{x:Static Visibility.Collapsed}" KeyTime="00:00:0.75" /> </ObjectAnimationUsingKeyFrames> </Storyboard> <Storyboard x:Key="sbHideNested"> <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="NestedContentPresenter" Storyboard.TargetProperty="Opacity" FillBehavior="HoldEnd"> <SplineDoubleKeyFrame KeySpline="0.5,0.5,0.5,0.5" Value="1" KeyTime="00:00:00.15" /> </DoubleAnimationUsingKeyFrames> </Storyboard> </ControlTemplate.Resources> <Grid Background="{TemplateBinding Background}"> <Grid.ColumnDefinitions> <ColumnDefinition Width="*" MinWidth="20" /> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition Height="Auto" /> <RowDefinition Height="*" /> </Grid.RowDefinitions> <!-- Row for nested content --> <!-- Record content site --> <Grid x:Name="PART_RecordContentSite" Margin="0" Grid.Row="1" Grid.Column="0" Visibility="Collapsed" d:LayoutOverrides="GridBox"> <!-- Background Bar --> <Border HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="Auto" Height="Auto" RenderTransformOrigin="0.5,0.5" CornerRadius="2,2,2,2" SnapsToDevicePixels="True" Background="{DynamicResource {ComponentResourceKey {x:Type igDP:XamDataGrid}, LabelBackground}}"> <Grid Margin="0,0,0,0" Width="Auto" Height="Auto"> <Rectangle Stroke="#44000000" StrokeThickness="1" RadiusX="1.55015910897703" RadiusY="1.55015910897703" Fill="Transparent" /> <Rectangle Margin="1" Stroke="#44FFFFFF" StrokeThickness="1" RadiusX="0.550159108977027" RadiusY="0.550159108977027" Fill="Transparent" /> </Grid> </Border> <!-- End Background Bar --> <Border x:Name="highlight" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="Auto" Height="Auto" CornerRadius="2,2,2,2" Background="{DynamicResource {ComponentResourceKey {x:Type igDP:XamDataGrid}, LabelHighlight}}"> <Grid Margin="0,0,0,0" Width="Auto" Height="Auto"> <Rectangle Stroke="#44000000" StrokeThickness="1" RadiusX="1.55015910897703" RadiusY="1.55015910897703" Fill="Transparent" /> <Rectangle Margin="1" Stroke="#44FFFFFF" StrokeThickness="1" RadiusX="0.550159108977027" RadiusY="0.550159108977027" Fill="Transparent" /> </Grid> </Border> <!-- End Add 8/1/2006 GH--> <!-- Label Text --> <Grid> <ContentControl Style="{StaticResource LabelContentStyle}" Content="{Binding Path=Description, RelativeSource={RelativeSource TemplatedParent}}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" /> <!-- SSP 4/3/08 - Summaries Functionality --> <igDP:GroupBySummariesPresenter Grid.Row="1" HorizontalAlignment="Left" x:Name="GroupBySummariesPresenter" Visibility="Collapsed" GroupByRecord="{TemplateBinding Record}" /> </Grid> </Grid> <!-- Nested Content --> <Grid x:Name="PART_NestedContentSite" Grid.Row="1" Grid.Column="0" Visibility="Collapsed"> <!--<igWindows:NestedContentBackground/>--> <Border CornerRadius="0,0,3,3" BorderBrush="#44102975" BorderThickness="1"> <Border.Background> <LinearGradientBrush StartPoint="0,0" EndPoint="0,1"> <GradientStop Color="#FFFFFFFF" Offset="0.25" /> <GradientStop Color="#FFEEEEEE" Offset="1.2" /> </LinearGradientBrush> </Border.Background> <!-- AS 3/25/09 TFS15801 --> <ContentControl x:Name="NestedContentPresenter" Content="{Binding Path=NestedContent, RelativeSource={RelativeSource TemplatedParent}}" Margin="0,0,0,5" /> </Border> <!-- AS 11/14/07 BR26035 The namescope was broken because the recordlistcontrol was not in the logical tree. We need to use a ContentControl instead so the content is made a logical child. --> <!-- AS 3/25/09 TFS15801 This should be nested within the Border above. <ContentControl x:Name="NestedContentPresenter" Content="{Binding Path=NestedContent, RelativeSource={RelativeSource TemplatedParent}}" Margin="0,0,0,5"/>--> </Grid> </Grid> <ControlTemplate.Triggers> <Trigger Property="ShouldDisplayGroupByRecordContent" Value="true"> <Setter TargetName="PART_RecordContentSite" Property="Visibility" Value="Visible" /> </Trigger> <!--<Trigger Property="ShouldDisplayGroupByRecordContent" Value="false"/>--> <!-- SSP 4/3/08 - Summaries Functionality --> <Trigger Property="ShouldDisplaySummaryCells" Value="true"> <Setter TargetName="GroupBySummariesPresenter" Property="Visibility" Value="Visible" /> </Trigger> <Trigger Property="HasNestedContent" Value="true"> <Setter TargetName="PART_NestedContentSite" Property="Visibility" Value="Visible" /> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> </Setter.Value> </Setter> </Style>