This is a migrated thread and some comments may be shown as answers.

How can the footer cells content be horizontally centered?

3 Answers 291 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Calvin
Top achievements
Rank 2
Calvin asked on 22 Jul 2011, 11:52 PM
I'd like to have the footer cells' content be horizontally centered within the cells.  How can this be achieved?

I've tried the following:

<telerik:GridViewDataColumn DataMemberBinding="{Binding HubAssemblyNumber}"
                            FooterCellStyle="{StaticResource GridViewFooterCellStyle1}">
    <telerik:GridViewDataColumn.Header>
        <TextBlock Style="{StaticResource centeredHeaderTextBoxStyle}">
            <TextBlock.Inlines>
                <Run>Assembly</Run>
                <LineBreak />
                <Run>Number</Run>
            </TextBlock.Inlines>
        </TextBlock>
    </telerik:GridViewDataColumn.Header>
    <telerik:GridViewDataColumn.AggregateFunctions>
        <telerik:CountFunction Caption="Count: "
                                ResultFormatString="{StaticResource commaFormat}" />
    </telerik:GridViewDataColumn.AggregateFunctions>
 
    <telerik:GridViewDataColumn.Footer>
        <telerik:AggregateResultsList ItemsSource="{Binding}"
                                        HorizontalAlignment="Center"
                                        HorizontalContentAlignment="Center" >
            <ItemsControl.ItemTemplate>
                <DataTemplate>
                    <TextBlock HorizontalAlignment="Center"
                                Text="{Binding FormattedValue}" />
                </DataTemplate>
            </ItemsControl.ItemTemplate>
            <ItemsControl.ItemsPanel>
                <ItemsPanelTemplate>
                    <Grid HorizontalAlignment="Center" />
                </ItemsPanelTemplate>
            </ItemsControl.ItemsPanel>
        </telerik:AggregateResultsList>
    </telerik:GridViewDataColumn.Footer>
 
</telerik:GridViewDataColumn>

And I've tried it both with and without a custom footer style:

<Style x:Key="GridViewFooterCellStyle1"
        TargetType="{x:Type telerik:GridViewFooterCell}">
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="{x:Type telerik:GridViewFooterCell}">
                <Border x:Name="PART_FooterCellBorder"
                    <ContentPresenter ContentTemplate="{TemplateBinding ContentTemplate}"
                                        Content="{TemplateBinding Content}"
                                        HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" />
                </Border>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
    <Setter Property="HorizontalContentAlignment"
            Value="Center" />
    <Setter Property="HorizontalAlignment"
            Value="Stretch" />
</Style>

Moreover, I've tweaked the various Horizontal[Content]Alignment properties.  But so far my fiddling hasn't yielded the desired behavior.

I appreciate the help.  Thanks!

3 Answers, 1 is accepted

Sort by
0
Miles
Top achievements
Rank 1
answered on 25 Jul 2011, 03:14 AM
I have the same problem. Trying to right align. It always seems to stay left aligned.
0
Vanya Pavlova
Telerik team
answered on 25 Jul 2011, 08:10 AM
Hi Calvin,

 

You may achieve the desired resulkt only by setting FooterTextAlignment property of the corresponding column:

<Grid x:Name="LayoutRoot" Background="White" DataContext="{Binding Source={StaticResource SampleDataSource}}">
        <telerik:RadGridView ShowColumnFooters="True" ItemsSource="{Binding Collection}">
            <telerik:RadGridView.Columns>
                <telerik:GridViewDataColumn FooterTextAlignment="Center" Header="1" DataMemberBinding="{Binding Property1}">
                    <telerik:GridViewDataColumn.AggregateFunctions>
                        <telerik:CountFunction Caption="Count:"/>
                        </telerik:GridViewDataColumn.AggregateFunctions>
                    </telerik:GridViewDataColumn>
                </telerik:RadGridView.Columns>
            </telerik:RadGridView>
    </Grid>

Regards,
Vanya Pavlova
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

0
Miles
Top achievements
Rank 1
answered on 25 Jul 2011, 08:17 AM
Worked for me, thanks!
Tags
GridView
Asked by
Calvin
Top achievements
Rank 2
Answers by
Miles
Top achievements
Rank 1
Vanya Pavlova
Telerik team
Share this question
or