How to get instance of Panel that holds content of ItemsControl?
It’s a little tricky since you don’t know the name of the Panel so you can’t use FindName etc. This will work for most cases where an ItemsPresenter is present private Panel GetItemsPanel(DependencyObject itemsControl) { ItemsPresenter itemsPresenter = GetVisualChild<ItemsPresenter>(itemsControl); Panel itemsPanel = VisualTreeHelper.GetChild(itemsPresenter, 0) as Panel; return itemsPanel; } An implementation of GetVisualChild private static … Read more