ItemContainer既存のItemsControlオブジェクトから型を判別したい。
var item = control as ItemsControl;
//HOW to get child container Type?
Blend でそれがどのように行われるかの例:

Blend はどういうわけか、現在のTabControlタイプの子項目がであると判断しますTabItem。
コードで同じことを行う方法は?
ItemContainer既存のItemsControlオブジェクトから型を判別したい。
var item = control as ItemsControl;
//HOW to get child container Type?
Blend でそれがどのように行われるかの例:

Blend はどういうわけか、現在のTabControlタイプの子項目がであると判断しますTabItem。
コードで同じことを行う方法は?
StyleTypedPropertyAttributeから派生したほとんどのクラスにがありItemsControlます。Propertyに等しいものを取得し"ItemContainerStyle"ます。このStyleTargetType属性のプロパティは、項目タイプを提供する必要があります。
基本クラスから属性を取得しないように注意する必要があることに注意してください。また、これはほとんどのタイプ ( TabControl、ListBox) で機能しますが、 などの一部のクラスにDataGridは、この属性で注釈が付けられていません。
組み込みフレームワークの種類に使用するリストは次のとおりです。
var _itemsContainerTypeByContainerType = new Dictionary<Type, Type> {
{ typeof(ComboBox), typeof(ComboBoxItem) },
{ typeof(ContextMenu), typeof(MenuItem) },
{ typeof(DataGrid), typeof(DataGridRow) },
{ typeof(DataGridCellsPresenter), typeof(DataGridCell) },
{ typeof(DataGridColumnHeadersPresenter), typeof(DataGridColumnHeader) },
{ typeof(HeaderedItemsControl), typeof(ContentPresenter) },
{ typeof(ItemsControl), typeof(ContentPresenter) },
{ typeof(ListBox), typeof(ListBoxItem) },
{ typeof(ListView), typeof(ListViewItem) },
{ typeof(Menu), typeof(MenuItem) },
{ typeof(MenuBase), typeof(MenuItem) },
{ typeof(MenuItem), typeof(MenuItem) },
{ typeof(MultiSelector), typeof(ContentPresenter) },
{ typeof(Selector), typeof(ContentPresenter) },
{ typeof(StatusBar), typeof(StatusBarItem) },
{ typeof(TabControl), typeof(TabItem) },
{ typeof(TreeView), typeof(TreeViewItem) },
{ typeof(TreeViewItem), typeof(TreeViewItem) }
};