xaml-resources

How to get the root element inside an applied DataTemplate when it does not have a resource key?

断了今生、忘了曾经 提交于 2019-12-11 04:10:18
问题 I wish to get the root element inside an applied DataTemplate . I tried this but it does not work for me, because for the ContentPresenter returned by MyItemsControl.ItemContainerGenerator.ContainerFromItem(vm) where vm is a ViewModel, ContentPresenter.ContentTemplate is null , although ContentPresenter.Content is the corresponding data (the same ViewModel). I would access DataTemplate s as resources like here but I cannot give the DataTemplate s resource keys because I want them to be