I want to create an attached property that can be used with this syntax:
<Button>
<Image .../>
<ui:ToolbarItem.DisplayFilter>
<TabItem .../>
<TabItem .../>
<TabItem .../>
</ui:ToolbarItem.DisplayFilter>
</Button>
This is my attempt at doing so:
public class ToolbarItem
{
/// <summary>
/// Identifies the DisplayFilter attached property.
/// </summary>
public static readonly DependencyProperty DisplayFilterProperty =
DependencyProperty.RegisterAttached(
"DisplayFilter",
typeof( IList ),
typeof( ToolbarItem )
);
public static IList GetDisplayFilter( Control item ) {
return (IList)item.GetValue( DisplayFilterProperty );
}
public static void SetDisplayFilter( Control item, IList value ) {
item.SetValue( DisplayFilterProperty, value );
}
}
This, however, is causing an exception at parse-time -- System.ArgumentException: TabItem is not a valid value for property 'DisplayFilter'. So how do I configure my attached property so that I can use the desired XAML syntax?