<Grid> <Grid.Resources> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="Styles.xaml"/> </ResourceDictionary.MergedDictionaries> </ResourceDictionary> </Grid.Resources> <telerik:RadDataForm x:Name="DataForm"> <telerik:RadDataForm.ReadOnlyTemplate> <DataTemplate> <TextBox x:Name="textBox" Width="200" ContextMenu="{x:Null}" VerticalAlignment="Top" Margin="141,125,176,0"> <telerik:RadContextMenu.ContextMenu> <telerik:RadContextMenu x:Name="ContextMenuHugo" ItemContainerStyle="{StaticResource MenuItemContainer}" Opening="ContextMenuHugo_OnOpening"> </telerik:RadContextMenu> </telerik:RadContextMenu.ContextMenu> </TextBox> </DataTemplate> </telerik:RadDataForm.ReadOnlyTemplate> </telerik:RadDataForm> <TextBox x:Name="textBox" Width="200" ContextMenu="{x:Null}" VerticalAlignment="Top" Margin="141,125,176,0"> <telerik:RadContextMenu.ContextMenu> <telerik:RadContextMenu x:Name="ContextMenuHugo" ItemContainerStyle="{StaticResource MenuItemContainer}" > </telerik:RadContextMenu> </telerik:RadContextMenu.ContextMenu> </TextBox> </Grid><Grid> <Grid.Resources> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="Styles.xaml"/> </ResourceDictionary.MergedDictionaries> </ResourceDictionary> </Grid.Resources> <telerik:RadDataForm x:Name="DataForm"> <telerik:RadDataForm.ReadOnlyTemplate> <DataTemplate> <TextBox x:Name="textBox" Width="200" ContextMenu="{x:Null}" VerticalAlignment="Top" Margin="141,125,176,0"> <telerik:RadContextMenu.ContextMenu> <telerik:RadContextMenu x:Name="ContextMenuHugo" ItemContainerStyle="{StaticResource MenuItemContainer}" Opening="ContextMenuHugo_OnOpening"> </telerik:RadContextMenu> </telerik:RadContextMenu.ContextMenu> </TextBox> </DataTemplate> </telerik:RadDataForm.ReadOnlyTemplate> </telerik:RadDataForm> <TextBox x:Name="textBox" Width="200" ContextMenu="{x:Null}" VerticalAlignment="Top" Margin="141,125,176,0"> <telerik:RadContextMenu.ContextMenu> <telerik:RadContextMenu x:Name="ContextMenuHugo" ItemContainerStyle="{StaticResource MenuItemContainer}" > </telerik:RadContextMenu> </telerik:RadContextMenu.ContextMenu> </TextBox> </Grid>I want to put some text in the footer of a column in my gridview. However I can't get the binding to work.
I'm using MVVM. I have one viewmodel for the whole form including the gridview (let's call this MainViewModel) and also one viewmodel per row in the gridview (RowViewModel).
The text I want to show in the footer is in MainViewModel (let's call the property FooterText). How can I bind the text of the footer to this property?
My footer looks like this:
<telerikGridView:GridViewDataColumn.Footer> <TextBlock Text="Testing" /></telerikGridView:GridViewDataColumn.Footer>This example works and displays the text "Testing" in the footer. But my problems starts when I try to set the text using binding instead.
This doesn't work:
<telerikGridView:GridViewDataColumn.Footer> <TextBlock Text="{Binding Path=FooterText}" /></telerikGridView:GridViewDataColumn.Footer>
I've tried this:
<telerikGridView:GridViewDataColumn.Footer> <TextBlock Text="{Binding ElementName=LayoutRoot, Path=DataContext.FooterText}" /></telerikGridView:GridViewDataColumn.Footer>LayoutRoot is the Grid that is the root element of the form that the gridview resides in. This does not work. What confuses me is that I can bind the Header of the column in the exact way and it works:
<telerikGridView:GridViewDataColumn Header="{Binding ElementName=LayoutRoot, Path=DataContext.FooterText}" ... >
I've also tried this:
<telerikGridView:GridViewDataColumn.Footer> <TextBlock Text="{Binding Path=DataContext.FooterText, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=telerikGridView:RadGridView}}" /></telerikGridView:GridViewDataColumn.Footer>This didn't work neither.
Any more ideas?