Hi,
I need to bind the Footer column field with the view model property. I dont need the default aggregation values.
Following is my source:
<telerikGridView:GridViewDataColumn CellStyle="{x:Null}"
Header="Total Price"
IsReadOnly="True"
TextAlignment="Right"
DataMemberBinding="{Binding TotalPrice, Mode=OneWay, Converter={StaticResource CurrencyValueConverter}}"
SortMemberPath="{x:Null}"
Width="Auto" >
<
telerikGridView:GridViewDataColumn.Footer>
<StackPanel Orientation="Vertical" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Margin="1,1,1,1">
<TextBlock
VerticalAlignment="Bottom"
HorizontalAlignment="Right"
Text="{Binding WorkOrderTotalPrice, Mode=OneWay, Converter={StaticResource CurrencyValueConverter}}" />
</StackPanel>
</telerikGridView:GridViewDataColumn.Footer>
</telerikGridView:GridViewDataColumn>
I am using a view model which contains the TotalPrice and WorkOrderTotalPrice properties. I need to bind the WorkOrderTotalPrice property in to the Footer field.
The above source is not working. Please let me know, how could i bind it?
10 Answers, 1 is accepted
Firstly, you may take a look at our demo for examples on the way of defining and exploring the column footers. Furthermore, you may try the approach of defining your ViewModel in the Resources section and then use it as a StaticResource as the Source property in the definition of your Binding.
Maya
the Telerik team

Hi,
My page's DataContext is already bound with the ViewModel. I am using the MVVM design model. The same page has some other conrtols which has the values bound with the Viewmodel and they are showing the values properly.
Do i need to put the viewModel as my Static Resource? Then only can i access the values in footer?

i have the same problem. The textbox shows no data from the viewmodel in the datacontext.
I defined the footer in the xaml like this:
<
telerik:GridViewDataColumn
Header
=
"Bestellungen"
IsGroupable
=
"False"
UniqueName
=
"BANZAHL"
DataMemberBinding
=
"{Binding BANZAHL}"
SortingState
=
"Descending"
DataFormatString
=
"N0"
TextAlignment
=
"Right"
SortMemberPath
=
"BANZAHL"
IsVisible
=
"{Binding ColumnBanzahlIsVisibleB}"
>
<
telerik:GridViewDataColumn.Footer
>
<
StackPanel
Orientation
=
"Horizontal"
>
<
TextBox
Text
=
"{Binding SumBestellungen, Mode=TwoWay}"
DataContext
=
"{Binding ElementName=LayoutRoot, Path=DataContext}"
/>
</
StackPanel
>
</
telerik:GridViewDataColumn.Footer
>
</
telerik:GridViewDataColumn
>
But, when i copy the definition of the textbox outside the grid, it immediatly works.
There is no way for me to create the viewmodel as a static resouce because i need some parameters in the constructor.
I think, this is some bug in the Gridview Q3.
Greetings,
Sascha
Indeed one possible approach is to define the ViewModel in the Resources section and use it as a StaticResource afterwards. Another way for handling such a scenario is described in online documentation. The example is based on the Header of the column, but the idea is the same.
Maya
the Telerik team

unfortunaly your hint to the online documentation didn't work. The Header and the Footer are still emtpy.
Using a DataContextProxy helped me solving the problem.
Greetings,
Sascha

<
telerik:GridViewColumn.FooterCellStyle
>
<
Style
TargetType
=
"telerik:GridViewFooterCell"
>
<
Setter
Property
=
"ContentTemplate"
>
<
Setter.Value
>
<
DataTemplate
>
<
TextBlock
Text
=
"{Binding Text, ElementName=TextBlock}"
/>
</
DataTemplate
>
</
Setter.Value
>
</
Setter
>
</
Style
>
</
telerik:GridViewColumn.FooterCellStyle
>
In the online documentation link provided, there is an example of binding to a Header. The trick is bind to a HeaderCellStyle (or FooterCellStyle in my case) instead of binding to the header itself. Just wanted to share this little piece of info in the event that somebody else was searching for a solution and came across this thread.
Paul
Thank you for sharing the code-snippet. It extends the example in our documentation by demonstrating how to achieve the desired result in the columns' footers.
Maya
the Telerik team

I can't get the 'GridViewFooterCell' class from:
"clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.GridView"
is it new? from which version?Thanks,
Viki
You can get the GridViewFooterCell from:
xmlns:telerik="clr-namespace:Telerik.Windows.Controls.GridView;assembly=Telerik.Windows.Controls.GridView"
However, I would recommend you to use the uri namespace:
xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
Thus you will be able to reference all the controls, whose assemblies have been added to your project and you will not have to take care which namespace exactly you need.
Kind regards,
Maya
the Telerik team

I just had to add the alias for to get the class, as follows:
<
telerik:GridViewColumn.FooterCellStyle
>
<
Style
TargetType
=
"telerik:GridViewFooterCell"
>
.......
and not just:
<
telerik:GridViewColumn.FooterCellStyle
>
<
Style
TargetType
=
"GridViewFooterCell"
>