I've a GridView which has RowDetail. I want to each time user clicks on the rows get some detail from database, I use Telerik GridView. In normal way it's not possible or at least I don't know how, because RowDetail context binded directly to the grid DataContext, what I want is more than what GridRow contains it. What I found is maybe I can set RowDetailTemplate DataContext to UserControl by naming the UserControl so I can reference RowDetail to other model.
My code is something like this
<UserControl
x:Name="mainPageView"
x:Class="Project.Client.TestView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.GridView"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="400">
<UserControl.Resources>
<DataTemplate x:Key="ContactRowDetailTemplate" >
<Grid Background="Transparent"
DataContext="{Binding DataContext.ContactStatModel,
ElementName=mainPageView,Mode=OneTime}">
<Grid.RowDefinitions>
<RowDefinition Height="28" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBlock Text="Sent SMS Count" Grid.Column="0" Grid.Row="0" />
<TextBlock Text=":" Grid.Column="1" Grid.Row="0" />
<TextBlock Text="{Binding SMSCount}" Grid.Column="2" Grid.Row="0" />
</Grid>
</DataTemplate>
</UserControl.Resources>
<telerik:RadGridView
x:Name="gridView"
AutoGenerateColumns="False" Height="Auto" Grid.Row="3"
ItemsSource="{Binding VOutboxList, Mode=TwoWay}"
SelectedItem="{Binding VOutboxModel, Mode=TwoWay}"
RowDetailsTemplate="{StaticResource ContactRowDetailTemplate}"
LoadingRowDetails="gridView_LoadingRowDetails">
<telerik:RadGridView.Columns>
<telerik:GridViewDataColumn UniqueName="FirstName" Header="First Name" Width="150" />
<telerik:GridViewDataColumn UniqueName="LastName" Header="Last Name" Width="150" />
</telerik:RadGridView.Columns>
</telerik:RadGridView>
</UserControl>
But this time I get this exception
{Error: System.Exception: BindingExpression_CannotFindElementName}
Any advice will be helpful. Best Regards.