we are trying to add ColumnDefinition to a Grid in WPF dynamically from code behind. The question is: when do you do that? In the Usercontrol's Loaded event? We have a ListView that utilizes a DataTemplate which in turn uses the Grid. How do you access that Grid instance (the one inside a DataTemplate) from code behind? It does have ax:Name but it is not visible in the UserControl's code. Thanks for your help.
You can walk the logical tree using the VisualTreeHelper , then programatically create column definitions.
Here is a good article on using the Visual and Logical trees and how to navigate them effectively.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.