Hello,
I have a telerik gridview that has a RowDetailsTemplate set. In that template i have a contencontrol defined as shown in the example:
VMC is a custom control that allows me to reference the ViewModel, even when the datacontext of the DataTemplate is set to the selected item in the grid.
CostCenterDistributionListViewModel is a ViewModel to which a reference is held in the ViewModel of the page that holds the gridview with the rowdetails. Each time another Vacancy (item in the grid) is selected, the CostcenterDistributionListViewModel is created and initialized again.
The first time that I select a row, the details are shown as expected. But when I select another row, I get the Xaml parse exception: "Element is already the child of another element".
I've tried to solve this, by explicitly setting the CostCenterDistributionListViewModel to null before creating it again. I've also tried to Dispose the viewmodel before creating it again, but that doesn't seem to work.
When I put something else in the rowdetailstemplate (eg a TextBox), then the exception is not thrown.
Any other ideas?
Thanks,
Sodi
I have a telerik gridview that has a RowDetailsTemplate set. In that template i have a contencontrol defined as shown in the example:
<
DataTemplate
x:Key
=
"VacancyRowDetailsTemplate"
>
<
ContentControl
Content
=
"{Binding ViewModel.CostCenterDistributionListViewModel.View, Source={StaticResource VMC}}"
Style
=
"{StaticResource ContentControlStyle}"
/>
</
DataTemplate
>
VMC is a custom control that allows me to reference the ViewModel, even when the datacontext of the DataTemplate is set to the selected item in the grid.
CostCenterDistributionListViewModel is a ViewModel to which a reference is held in the ViewModel of the page that holds the gridview with the rowdetails. Each time another Vacancy (item in the grid) is selected, the CostcenterDistributionListViewModel is created and initialized again.
The first time that I select a row, the details are shown as expected. But when I select another row, I get the Xaml parse exception: "Element is already the child of another element".
I've tried to solve this, by explicitly setting the CostCenterDistributionListViewModel to null before creating it again. I've also tried to Dispose the viewmodel before creating it again, but that doesn't seem to work.
When I put something else in the rowdetailstemplate (eg a TextBox), then the exception is not thrown.
Any other ideas?
Thanks,
Sodi