I defined a custom attached property as follows:
public class DataFilter
{
public static readonly DependencyProperty FilterColumnProperty =
DependencyProperty.RegisterAttached("FilterColumn", typeof (string), typeof (DataFilter),
new FrameworkPropertyMetadata(string.Empty,
FrameworkPropertyMetadataOptions.Inherits));
public static void SetFilterColumn(UIElement element, string value)
{
element.SetValue(FilterColumnProperty, value);
}
public static string GetFilterColumn(UIElement element)
{
return (string) element.GetValue(FilterColumnProperty);
}
}
I use it in my XAML as follows:
<Grid Height="600" Name="grdData" cmds:DataFilter.FilterColumn="datasource_id">
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
<RowDefinition Height="25"></RowDefinition>
<RowDefinition Height="50"></RowDefinition>
</Grid.RowDefinitions>
<igDP:XamDataGrid Name="xamDataGrid1" VerticalAlignment="Top" DataSource="{Binding Tables[Table1]}" ActiveDataItem="{Binding SelectedItem, Mode=OneWayToSource}" cmds:DataFilter.FilterColumn="{Binding FilterCol, Mode=OneWayToSource">
The goal is to be able to bind the inherited nested value of the cmds: DataFilter.FilterColumn property to the VM FilterCol property. I don’t know how to achieve this. The above / XAML code sets the property of the attached property (strng.Empty) to the default value for the VM property, which is due to the fact that it creates a new instance of the attached property in the child control. I don’t know what XAML syntax to use to bind it to the value set in the Grid (parent) control.