共用方式為


DataContextValueSourceAttribute 建構函式 (String, String, Boolean)

使用指定的屬性名稱、上階路徑和集合資訊,初始化 DataContextValueSourceAttribute 類別的新執行個體。

命名空間:  Microsoft.Windows.Design
組件:  Microsoft.Windows.Design.Interaction (在 Microsoft.Windows.Design.Interaction.dll 中)

語法

'宣告
Public Sub New ( _
    dataContextValueSourceProperty As String, _
    ancestorPath As String, _
    isCollectionItem As Boolean _
)
public DataContextValueSourceAttribute(
    string dataContextValueSourceProperty,
    string ancestorPath,
    bool isCollectionItem
)
public:
DataContextValueSourceAttribute(
    String^ dataContextValueSourceProperty, 
    String^ ancestorPath, 
    bool isCollectionItem
)
new : 
        dataContextValueSourceProperty:string * 
        ancestorPath:string * 
        isCollectionItem:bool -> DataContextValueSourceAttribute
public function DataContextValueSourceAttribute(
    dataContextValueSourceProperty : String, 
    ancestorPath : String, 
    isCollectionItem : boolean
)

參數

  • dataContextValueSourceProperty
    型別:System.String
    屬性名稱,此屬性為資料內容之值的來源。
  • ancestorPath
    型別:System.String
    屬性路徑,表示要周遊到達資料內容屬性的上階屬性集。
  • isCollectionItem
    型別:System.Boolean
    表示資料內容是否為集合中的項目。

備註

下列 XAML 片段會顯示具有多個不同資料內容的樹狀目錄。

<ListView.View>
    <GridView>
        <GridViewColumn Header="Customer ID" Width="80">
            <GridViewColumn.CellTemplate>
                <DataTemplate>

下列程式碼示範如何指定資料內容繼承的上階路徑。 builder 是對 AttributeTableBuilder 執行個體的參考。 這個程式碼指定 CellTemplate 屬性的屬性路徑是「View」、「Columns」和「 」。

builder.AddCustomAttributes("CellTemplate", new DataContextPropertyAttribute("ItemsSource", @"(ListView.View).(GridView.Columns)\", true));

.NET Framework 安全性

請參閱

參考

DataContextValueSourceAttribute 類別

DataContextValueSourceAttribute 多載

Microsoft.Windows.Design 命名空間

其他資源

了解 WPF 設計工具擴充性