Welcome to the Xceed Community | Help
Community Search  
More Search Options

Group Header text change

Sort Posts: Previous Next
  •  07-14-2009, 3:05 AM Post no. 22537

    Group Header text change

    Attachment: clip_image001.jpg

    We need a clarification on the changing the group header text when displaying in the grid. The grid needs to display the first row all columns text as the header. Is this possible?

    Also need this to happen in the code behind.  Please provide some examples of how to do in code behind

     

    Please find the screenshot as of how we need the display in the grid attached.


  •  07-14-2009, 1:19 PM Post no. 22561 in reply to 22537

    Re: Group Header text change

    Hi Kamesh,

    The following code snippet addresses your issue to display the first row of group items into the group header control.

     

    For example:

     

          <DataTemplate x:Key="groupingComboBoxItemTemplate"

                        DataType="local:GroupingItem">

             <TextBlock Text="{Binding Description}"

                        Margin="2,0,6,0"/>

          </DataTemplate>

     

            <ControlTemplate x:Key="groupExpanderToggleButtonTemplate"

                             TargetType="ToggleButton">

     

                <ContentPresenter x:Name="expanderGlyphPresenter"

                                  Content="{x:Null}"

                                  ContentTemplate="{Binding RelativeSource={RelativeSource Self}, Path=(xcdg:DataGridControl.DataGridContext).CollapseGroupGlyph}" />

     

                <ControlTemplate.Triggers>

                    <Trigger Property="IsChecked"

                             Value="False">

                        <Setter TargetName="expanderGlyphPresenter"

                                Property="ContentTemplate"

                                Value="{Binding RelativeSource={RelativeSource Self}, Path=(xcdg:DataGridControl.DataGridContext).ExpandGroupGlyph}" />

                    </Trigger>

                </ControlTemplate.Triggers>

            </ControlTemplate>

          

            <xcdg:IntAdditionConverter x:Key="groupHeaderControlGroupLevelConverter" />

            <ControlTemplate x:Key="customtableViewGroupHeaderControlTemplate"

                             TargetType="xcdg:GroupHeaderControl">

     

                <!-- Using this decorator will prevent the GroupHeaderControl of exceeding the width

               defined by the grid's column. -->

                <xcdg:PassiveLayoutDecorator Axis="Horizontal">

                    <!-- This DockPanel is used to layout the GroupLevelIndicatorPane placeholder and the GroupHeaderControl Content. -->

                    <DockPanel>

     

                        <!-- GroupLevelIndicatorPane is a placeholder for individual GroupLevelIndicator elements that are added

                  whenever this GroupHeaderControl is part of a group. -->

                        <xcdg:HierarchicalGroupLevelIndicatorPane DockPanel.Dock="Left" />

                        <xcdg:GroupLevelIndicatorPane DockPanel.Dock="Left"

                                                      Indented="False"

                                                      xcdg:GroupLevelIndicatorPane.GroupLevel="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(xcdg:GroupLevelIndicatorPane.GroupLevel), Converter={StaticResource groupHeaderControlGroupLevelConverter}, ConverterParameter=-1}" />

     

                        <!-- Main Border for the GroupHeaderControl. It is Focusable to make the InputBindings work. -->

                        <Border x:Name="mainBorder"

                                Background="{TemplateBinding Background}"

                                BorderBrush="{TemplateBinding BorderBrush}"

                                BorderThickness="{TemplateBinding BorderThickness}"

                                Padding="{TemplateBinding Padding}"

                                Focusable="True"

                                FocusVisualStyle="{TemplateBinding FocusVisualStyle}">

     

                            <!-- Define all the standard InputBindings for a GroupHeaderControl. -->

                            <Border.InputBindings>

                                <KeyBinding Command="{x:Static xcdg:DataGridCommands.ToggleGroupExpansion}"

                                            Key="Space" />

     

                                <KeyBinding Command="{x:Static xcdg:DataGridCommands.ExpandGroup}"

                                            Key="Right" />

     

                                <KeyBinding Command="{x:Static xcdg:DataGridCommands.ExpandGroup}"

                                            Key="Add" />

     

                                <KeyBinding Command="{x:Static xcdg:DataGridCommands.CollapseGroup}"

                                            Key="Left" />

     

                                <KeyBinding Command="{x:Static xcdg:DataGridCommands.CollapseGroup}"

                                            Key="Subtract" />

     

                                <MouseBinding Command="{x:Static xcdg:DataGridCommands.ToggleGroupExpansion}"

                                              MouseAction="LeftDoubleClick" />

     

                            </Border.InputBindings>

     

                            <!-- This StackPanel is used to layout the ToggleButton and the GroupHeaderControl. -->

                            <StackPanel Orientation="Horizontal">

     

                                <!-- ToggleButton that is used to expand/collapse the group. -->

                                <ToggleButton Template="{StaticResource groupExpanderToggleButtonTemplate}"

                                              OverridesDefaultStyle="True"

                                              VerticalAlignment="{TemplateBinding VerticalContentAlignment}"

                                              Focusable="False"

                                              IsChecked="{Binding RelativeSource={RelativeSource TemplatedParent},Path=Group.IsExpanded}"

                                              Margin="-15"/>

     

                                <!-- ContentPresenter in charge of displaying this GroupHeaderControl's Content, which is

                                 a Group by default. -->

                                <local:customDataRow cvg="{Binding RelativeSource={RelativeSource Self},Path=(xcdg:DataGridControl.StatContext)}" />

                            </StackPanel>

                        </Border>

                    </DockPanel>

                </xcdg:PassiveLayoutDecorator>

     

                <ControlTemplate.Triggers>

                    <Trigger Property="xcdg:DataGridControl.NavigationBehavior"

                             Value="None">

                        <Setter TargetName="mainBorder"

                                Property="Focusable"

                                Value="False" />

                    </Trigger>

                </ControlTemplate.Triggers>

     

            </ControlTemplate>

     

            <Style TargetType="xcdg:GroupHeaderControl">

                <Setter Property="Template"

                        Value="{StaticResource customtableViewGroupHeaderControlTemplate}" />

     

            </Style>

     

    public class customDataRow : Xceed.Wpf.DataGrid.Row

      {

     

        #region cvg Property

     

        public static readonly DependencyProperty cvgProperty = DependencyProperty.Register(

          "cvg",

          typeof( CollectionViewGroup ),

          typeof( customDataRow ),

          new FrameworkPropertyMetadata(

            null,

            new PropertyChangedCallback( customDataRow.OncvgChanged ) ) );

     

        public CollectionViewGroup cvg

        {

          get

          {

            return ( CollectionViewGroup )this.GetValue( customDataRow.cvgProperty );

          }

          set

          {

            this.SetValue( customDataRow.cvgProperty, value );

          }

        }

     

        private static void OncvgChanged( DependencyObject sender, DependencyPropertyChangedEventArgs e )

        {

     

        }

     

        #endregion

     

        public  customDataRow()

        {

        

          this.ReadOnly = true;

        }

        protected override Cell CreateCell( ColumnBase column )

        {

          Cell _Cell = new Cell();

          if( cvg != null )

          {

            _Cell.Content = ( ( System.Data.DataRowView )cvg.Items[ 0 ] ).Row[ column.FieldName ];

          }

          else

          {

     

            _Cell.FieldName = column.FieldName;

            _Cell.Content = column.Title;

          }

          return _Cell;

        }

     

        protected override bool IsValidCellType( Cell cell )

        {

          bool validity = true;

          return validity;

        }

      }

     


    Xceed - Software Developer and Technical Support
View as RSS news feed in XML
Contact | Site Map | Reviews | Legal Terms of Use | Trademarks | Privacy Statement Copyright 2011 Xceed Software Inc.