How to get general ItemContainer type for WPF ItemsControl
问题 I want to determine ItemContainer type from an existing ItemsControl object. var item = control as ItemsControl; //HOW to get child container Type? Example how blend does this: Blend somehow determines that current TabControl type child item is TabItem . How to do same thing in code? 回答1: There is a StyleTypedPropertyAttribute on most classes derived from ItemsControl . Get the one having Property equals to "ItemContainerStyle" . The StyleTargetType property on this attribute should give you