RelativeSource 建構函式
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
初始化 RelativeSource 類別的新執行個體。
多載
| 名稱 | Description |
|---|---|
| RelativeSource() |
初始化 RelativeSource 類別的新執行個體。 |
| RelativeSource(RelativeSourceMode) |
初始化類別的新實例 RelativeSource ,並以初始模式。 |
| RelativeSource(RelativeSourceMode, Type, Int32) |
初始化類別的新實例 RelativeSource ,並初始化初始模式及額外的樹行限定條件以尋找所需的相對來源。 |
RelativeSource()
初始化 RelativeSource 類別的新執行個體。
public:
RelativeSource();
public RelativeSource();
Public Sub New ()
適用於
RelativeSource(RelativeSourceMode)
初始化類別的新實例 RelativeSource ,並以初始模式。
public:
RelativeSource(System::Windows::Data::RelativeSourceMode mode);
public RelativeSource(System.Windows.Data.RelativeSourceMode mode);
new System.Windows.Data.RelativeSource : System.Windows.Data.RelativeSourceMode -> System.Windows.Data.RelativeSource
Public Sub New (mode As RelativeSourceMode)
參數
- mode
- RelativeSourceMode
這是其中一項 RelativeSourceMode 價值。
適用於
RelativeSource(RelativeSourceMode, Type, Int32)
初始化類別的新實例 RelativeSource ,並初始化初始模式及額外的樹行限定條件以尋找所需的相對來源。
public:
RelativeSource(System::Windows::Data::RelativeSourceMode mode, Type ^ ancestorType, int ancestorLevel);
public RelativeSource(System.Windows.Data.RelativeSourceMode mode, Type ancestorType, int ancestorLevel);
new System.Windows.Data.RelativeSource : System.Windows.Data.RelativeSourceMode * Type * int -> System.Windows.Data.RelativeSource
Public Sub New (mode As RelativeSourceMode, ancestorType As Type, ancestorLevel As Integer)
參數
- mode
- RelativeSourceMode
這是其中一項 RelativeSourceMode 價值。 為了讓這個簽名相關,這個應該是 FindAncestor。
- ancestorLevel
- Int32
該前祖先在所有相同類型祖先中所屬的序數位置。
範例
以下會返回從綁定目標元素開始的向上路徑中遇到的第二點 ItemsControl 。
Binding myBinding = new Binding();
// Returns the second ItemsControl encountered on the upward path
// starting at the target element of the binding
myBinding.RelativeSource = new RelativeSource(
RelativeSourceMode.FindAncestor, typeof(ItemsControl), 2);
Dim myBinding As New Binding()
' Returns the second ItemsControl encountered on the upward path
' starting at the target element of the binding
myBinding.RelativeSource = New RelativeSource(RelativeSourceMode.FindAncestor, GetType(ItemsControl), 2)
備註
ancestorType
ancestorLevel若作為除 mode以外的FindAncestor參數,則 與 無關。 其他值不要用這個簽名。RelativeSourceMode