Hi guys,
I'm actually displaying my RadGridView row details in a DetailPresenter (working withRadControls for WPF Q3 2012).
Each rows can be of different types, therefore, I use a template selector to display details. Templates are hosting user controls connected to ViewModels, instantiating in there own codebehind in onrender methods:
Mainwindow.xaml:
AdultView.xaml.cs:
This works quite well until I'm selecting a second line of the same type:
The user control placed in the selected template does not update it's binding handled by its ViewModel.
Do I implement things correctly(is onrender method the right place to instanciate the viewModel object)? Do I miss something?
Thanks for your help.
Kind regards,
JC
I'm actually displaying my RadGridView row details in a DetailPresenter (working withRadControls for WPF Q3 2012).
Each rows can be of different types, therefore, I use a template selector to display details. Templates are hosting user controls connected to ViewModels, instantiating in there own codebehind in onrender methods:
Mainwindow.xaml:
<Grid VerticalAlignment="Top"> <Grid.Resources> <DataTemplate x:Key="KidDataTemplate"> <View:KidView KidId="{Binding Id}" /> </DataTemplate> <DataTemplate x:Key="AdultDataTemplate"> <View:AdultView AdultId="{Binding Id}" /> </DataTemplate> <selectors:UserDataTemplateSelector x:Key="UserDataTemplateSelector" /> </Grid.Resources> <StackPanel Orientation="Vertical"> <telerik:RadGridView x:Name="grid1" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" RowDetailsTemplateSelector="{StaticResource UserDataTemplateSelector}" RowDetailsVisibilityMode="Collapsed" AutoGenerateColumns="True"/> <Border Grid.Row="1" BorderBrush="WhiteSmoke" BorderThickness="5"> <telerik:DetailsPresenter DetailsProvider="{Binding RowDetailsProvider, ElementName=grid1}" /> </Border> </StackPanel> </Grid>AdultView.xaml.cs:
public partial class AdultView : UserControl { public int? AdultId { get { return (int?)GetValue(AdultIdProperty); } set { SetValue(AdultIdProperty, value); } } public static readonly DependencyProperty AdultIdProperty = DependencyProperty.Register("AdultId", typeof(int?), typeof(AdultView)); public AdultView() { InitializeComponent(); } protected override void OnRender(DrawingContext drawingContext) { base.OnRender(drawingContext); if (AdultId.HasValue) { this.DataContext = new RowDetailSample.ViewModel.AdultViewModel(AdultId.Value); } } }This works quite well until I'm selecting a second line of the same type:
The user control placed in the selected template does not update it's binding handled by its ViewModel.
Do I implement things correctly(is onrender method the right place to instanciate the viewModel object)? Do I miss something?
Thanks for your help.
Kind regards,
JC