I have 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 am using 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 here is to be able to bind the inherited attached property value of cmds:DataFilter.FilterColumn to the VM property of FilterCol. Am not sure how to achieve this. The above code/XAML only sets the default value of the attached property (strng.Empty) to the VM property which is due to the fact that it is creating a new instance of the attached property in the child control. Am not sure what XAML syntax to use to get it to bind to the value set in the Grid (parent) control.