This question is locked. New answers and comments are not allowed.
Sukhvinder Pal
Top achievements
Rank 1
Sukhvinder Pal
asked on 08 Sep 2009, 09:32 AM
I was implementing a grid view with row details. And my binding was misbehaving. I found that "After the content of the Row Details DataTemplate is loaded, theFrameworkElement's DataContext property is assigned to theDataContext of the containing row". Can the datatemplate for row details have a binding same as the GridView object. How can it be done?
3 Answers, 1 is accepted
0
Accepted
Hi Sukhvinder Pal,
You can attach to the LoadingRowDetails event. Inside this event you will be presented with the FrameworkElement that was just created from the RowDetailsTemplate that you have specified.
You can change its DataContext to be anything in the world that you want without any problems. We simply set it to be the master row since 99% of the times, row details are used for displaying master-details relationships. But that is not obligatory. You code will come after ours so you can change everything.
Its just a FrameworkElement and you have the freedom to do anything with it -- change its DataContext or cast it to the class that it really is (i.e. the thing you placed inside the RowDetailsTemplate) and play with its ItemsSource, if it is an ItemsControl. It can be anything.
So the bottom-line is that you are free to manipulate the FrameworkElement in any way in the LoadingRowDetails event handler.
If you need to do perform something when details are being shown or hidden you should attach to the RowDetailsVisibilityChanged event.
I hope this helps. Please let me know if you have any other questions or problems with the Row Details.
Greetings,
Ross
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
You can attach to the LoadingRowDetails event. Inside this event you will be presented with the FrameworkElement that was just created from the RowDetailsTemplate that you have specified.
You can change its DataContext to be anything in the world that you want without any problems. We simply set it to be the master row since 99% of the times, row details are used for displaying master-details relationships. But that is not obligatory. You code will come after ours so you can change everything.
Its just a FrameworkElement and you have the freedom to do anything with it -- change its DataContext or cast it to the class that it really is (i.e. the thing you placed inside the RowDetailsTemplate) and play with its ItemsSource, if it is an ItemsControl. It can be anything.
So the bottom-line is that you are free to manipulate the FrameworkElement in any way in the LoadingRowDetails event handler.
If you need to do perform something when details are being shown or hidden you should attach to the RowDetailsVisibilityChanged event.
I hope this helps. Please let me know if you have any other questions or problems with the Row Details.
Greetings,
Ross
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Sukhvinder Pal
Top achievements
Rank 1
answered on 08 Sep 2009, 11:38 AM
Thanks for the quick reply. I tried the following(refer the data template below I want to add the 'currentDocInfolist' as children of Edit Metadata tree item. But it does not happen):
void radGridView_LoadingRowDetails(object sender, Telerik.Windows.Controls.GridView.GridViewRowDetailsEventArgs e)
{
Binding treeBinding = new Binding();
Grid templateRoot = e.DetailsElement as Grid;
treeBinding.Path = new PropertyPath("currentDocumentInfoList");
templateRoot.DataContext = this.ViewModel;
System.Collections.Generic.IList<RadTreeView> tree = templateRoot.ChildrenOfType<RadTreeView>();
RadTreeViewItem targetItem = tree[0].Items[0] as RadTreeViewItem;
targetItem.SetBinding(RadTreeView.ItemsSourceProperty, treeBinding);
}
<DataTemplate x:Key="PackageInfoDataTemplate">
<Grid x:Name="LayoutRoot">
<Grid.Resources>
<DataTemplate x:Key="DocInfo">
<TextBlock Text="{Binding Name}" />
</DataTemplate>
</Grid.Resources>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Border Name="PEBorder" BorderBrush="#FF000000" CornerRadius="7,0,0,7" BorderThickness="1" Grid.Column="0">
<telerikNavigation:RadTreeView x:Name="PackageExplorer" HorizontalAlignment="Left"
Margin="10" VerticalAlignment="Top" IsExpandOnSingleClickEnabled="True"
IsLineEnabled="True" SelectionMode="Single" IsEditable="False"
IsDragDropEnabled="False">
<telerikNavigation:RadTreeViewItem Header="Edit Metadata" IsExpanded="False"
Expanded="RadTreeViewItem_Expanded" DefaultImageSrc="">
<telerikNavigation:RadTreeViewItem Selected="RadTreeViewItem_Selected"
ItemTemplate="{StaticResource DocInfo}" >
</telerikNavigation:RadTreeViewItem>
</telerikNavigation:RadTreeViewItem>
</telerikNavigation:RadTreeView>
</Border>
<Border BorderBrush="#FF000000" CornerRadius="0,7,7,0" BorderThickness="1" Grid.Column="1">
<Grid Name="Details" >
</Grid>
</Border>
</Grid>
</DataTemplate>
0
Hi Sukhvinder Pal,
I have prepared a small sample project that you can use as a base.
It is my mistake that I forgot to mention that you will need the binaries from the Latest Internal Build for this to work properly. You can get the Latest Internal Build from your Client.Net.
Please, let me know if the problems still persist after upgrading to the latest version and examining my sample project.
Regards,
Ross
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
I have prepared a small sample project that you can use as a base.
It is my mistake that I forgot to mention that you will need the binaries from the Latest Internal Build for this to work properly. You can get the Latest Internal Build from your Client.Net.
Please, let me know if the problems still persist after upgrading to the latest version and examining my sample project.
Regards,
Ross
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.