Share via


DataContextValueSourceAttribute Constructor (String, String, Boolean)

Initializes a new instance of the DataContextValueSourceAttribute class with the specified property name, ancestor path, and collection information.

Namespace:  Microsoft.Windows.Design
Assembly:  Microsoft.Windows.Design.Interaction (in Microsoft.Windows.Design.Interaction.dll)

Syntax

'Declaration
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
)

Parameters

  • dataContextValueSourceProperty
    Type: System.String
    The name of the property that is the source of the data context’s value.
  • ancestorPath
    Type: System.String
    The property path that indicates the set of ancestor properties to traverse to reach the data context property.
  • isCollectionItem
    Type: System.Boolean
    Indicates whether the data context is an item in a collection.

Remarks

The following XAML fragment shows a tree with multiple different data contexts.

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

The following code shows how to specify the ancestor path for data context inheritance. builder is a reference to an AttributeTableBuilder instance. This code specifies that the property path to the CellTemplate property are "View", "Columns", and "".

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

.NET Framework Security

See Also

Reference

DataContextValueSourceAttribute Class

DataContextValueSourceAttribute Overload

Microsoft.Windows.Design Namespace

Other Resources

Understanding WPF Designer Extensibility