For example, my TreeViewItem' header consists of TextBlock and Image. How I can get references to them?
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
- How to know full paths to DLL's from .csproj f
I'm not sure if I got you right, but if you want to get visual children of an element, try using
VisualTreeHelper.GetChild
andVisualTreeHelper.GetChildrenCount
.PS: usually it's more problematic to get a reference to the TreeViewItem itself...
UPDATE (A code example for future generations):
If you have something like this (created in Xaml or code):
you can use something like:
I don't recommend doing this. It will be better if you create a custom header instead (a class that contains Image and TextBlock properties) and assign that to your header, or a custom Template.