When using SummaryOperands in a XamGrid with grouped rows, there are summary rows appearing at both the group level and at the bottom of the grid. I need to display only the one summary row at the bottom of the grid but I've been unable to find a way to turn off or hide the group summary rows. Any ideas?
Hi NLPatrick,
I'm putting together a sample to test with and I'd like to ask if you could provide the XAML you use to create your grid. This way I can make sure that my sample will follow your setup correctly.
I'm actually using the grid in a Lightswitch project. I created a usercontrol that contains a XamGrid. Here is the XAML for the usercontrol:
<UserControl x:Class="Tresys.Cascade.Custom.CascadeStaffingGrid" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:ig="http://schemas.infragistics.com/xaml" xmlns:igPrim="clr-namespace:Infragistics.Controls.Grids.Primitives;assembly=InfragisticsSL4.Controls.Grids.XamGrid.v11.2" mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="400"> <UserControl.Resources> <igPrim:SummaryResultFormatStringValueConverter x:Key="SDFormatStringConverter" /> <Style x:Key="SummaryRowCellsStyle" TargetType="igPrim:SummaryRowCellControl"> <Setter Property="Background" Value="WhiteSmoke" /> <Setter Property="SummaryDisplayTemplate"> <Setter.Value> <DataTemplate> <StackPanel Orientation="Horizontal" HorizontalAlignment="Right"> <TextBlock HorizontalAlignment="Right" Text="{Binding Converter={StaticResource SDFormatStringConverter}}" /> </StackPanel> </DataTemplate> </Setter.Value> </Setter> </Style> <Style x:Key="CompositeColumnStyle" TargetType="ig:CellControl"> <Setter Property="BorderThickness" Value="0"/> <Setter Property="Padding" Value="1 0 1 0"/> <Setter Property="HorizontalContentAlignment" Value="Stretch" /> </Style> </UserControl.Resources> <Grid x:Name="LayoutRoot" Background="White"> <ig:XamGrid HorizontalAlignment="Left" Name="xamGrid1" VerticalAlignment="Top"> <ig:XamGrid.SummaryRowSettings> <ig:SummaryRowSettings AllowSummaryRow="Bottom" SummaryScope="ColumnLayout" Style="{StaticResource SummaryRowCellsStyle}" /> </ig:XamGrid.SummaryRowSettings> </ig:XamGrid> </Grid> </UserControl>
Let me know if you have any questions on this matter.
From looking at your code I can't see anything that catches my eye. I assume you have some more stuff in code behind but without knowing that I can't replicate your grid exactly. I do however have an idea you can try that will let you hide the summary rows. Modify your SummaryRowCellStyle to include the following setter:
<Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="igPrim:SummaryRowCellControl"> <Grid Loaded="Grid_Loaded"> <VisualStateManager.VisualStateGroups> <VisualStateGroup x:Name="CommonStates"> <VisualState x:Name="Normal" /> <VisualState x:Name="MouseOver"/> <VisualState x:Name="Alternate" /> </VisualStateGroup> <VisualStateGroup x:Name="SelectedStates"> <VisualState x:Name="NotSelected"/> <VisualState x:Name="Selected"/> </VisualStateGroup> <VisualStateGroup x:Name="ActiveStates"> <VisualState x:Name="InActive" /> <VisualState x:Name="Active"> <Storyboard > <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00" Storyboard.TargetName="ActiveRect" Storyboard.TargetProperty="Visibility"> <DiscreteObjectKeyFrame KeyTime="00:00:00"> <DiscreteObjectKeyFrame.Value> <Visibility>Visible</Visibility> </DiscreteObjectKeyFrame.Value> </DiscreteObjectKeyFrame> </ObjectAnimationUsingKeyFrames> </Storyboard> </VisualState> </VisualStateGroup> <VisualStateGroup x:Name="FixedStates"> <VisualState x:Name="Fixed"/> <VisualState x:Name="Unfixed"/> </VisualStateGroup> </VisualStateManager.VisualStateGroups> <Border x:Name="AddNewRowElem" Background="{TemplateBinding Background}" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}"> <Rectangle Height="1" VerticalAlignment="Top" Fill="#7FFFFFFF"/> </Border> <Rectangle Fill="Transparent" Stroke="{StaticResource CellItemSelectedBorderBrush}" StrokeThickness="1" x:Name="ActiveRect" Visibility="Collapsed"></Rectangle> <StackPanel x:Name="SummaryDisplay" HorizontalAlignment="Right" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Margin="{TemplateBinding Padding}"/> </Grid> </ControlTemplate> </Setter.Value></Setter>
This will basically re-template the SummaryRowCellControl and add a Loaded event handler to it so we have a place to execute some code. The code to execute would look something like below.
private void Grid_Loaded(object sender, RoutedEventArgs e){ Grid grid = sender as Grid; SummaryRowCellControl summaryRowCellControl = VisualTreeHelper.GetParent(grid) as SummaryRowCellControl; CellsPanel cellPanel = VisualTreeHelper.GetParent(summaryRowCellControl) as CellsPanel; cellPanel.Height = 0;}
This will hide the summary row. Let me know if you have any questions on this.