ItemsControl.ContainerFromElement 方法
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
傳回擁有給定容器項目之目前 ItemsControl 所屬的容器。
ContainerFromElement(DependencyObject) |
傳回擁有給定項目之目前 ItemsControl 所屬的容器。 |
ContainerFromElement(ItemsControl, DependencyObject) |
傳回擁有給定容器項目之指定 ItemsControl 所屬的容器。 |
ContainerFromElement(DependencyObject)
傳回擁有給定項目之目前 ItemsControl 所屬的容器。
public:
System::Windows::DependencyObject ^ ContainerFromElement(System::Windows::DependencyObject ^ element);
C#
public System.Windows.DependencyObject ContainerFromElement (System.Windows.DependencyObject element);
member this.ContainerFromElement : System.Windows.DependencyObject -> System.Windows.DependencyObject
Public Function ContainerFromElement (element As DependencyObject) As DependencyObject
參數
- element
- DependencyObject
要為其傳回容器的項目。
傳回
擁有給定容器項目之目前 ItemsControl 所屬的容器,或是如果沒有這樣的容器存在則為 null
。
另請參閱
適用於
.NET Framework 4.8 和其他版本
產品 | 版本 |
---|---|
.NET Framework | 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8 |
Windows Desktop | 3.0, 3.1, 5, 6, 7 |
ContainerFromElement(ItemsControl, DependencyObject)
傳回擁有給定容器項目之指定 ItemsControl 所屬的容器。
public:
static System::Windows::DependencyObject ^ ContainerFromElement(System::Windows::Controls::ItemsControl ^ itemsControl, System::Windows::DependencyObject ^ element);
C#
public static System.Windows.DependencyObject ContainerFromElement (System.Windows.Controls.ItemsControl itemsControl, System.Windows.DependencyObject element);
static member ContainerFromElement : System.Windows.Controls.ItemsControl * System.Windows.DependencyObject -> System.Windows.DependencyObject
Public Shared Function ContainerFromElement (itemsControl As ItemsControl, element As DependencyObject) As DependencyObject
參數
- itemsControl
- ItemsControl
要為其傳回容器的 ItemsControl。
- element
- DependencyObject
要為其傳回容器的項目。
傳回
如果 itemsControl
不是 null
,則為擁有給定項目之指定 ItemsControl 所屬的容器。 如果 itemsControl
為 null
,則傳回任何 ItemsControl 所屬的最接近容器。
另請參閱
適用於
.NET Framework 4.8 和其他版本
產品 | 版本 |
---|---|
.NET Framework | 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8 |
Windows Desktop | 3.0, 3.1, 5, 6, 7 |