views:

699

answers:

0

Hi,

I have a UserControl Tasks.xaml that is used within a couple of property pages that inherit from a PropertyPageBase class - which itself inherits from UserControl. Within the Tasks UserControl, I want to use a Context menu command and the CommandParameter needs to bind to a DependencyProperty called Data on the PropertyPageBase class. Here is my attempt at the MenuItem:

<MenuItem Header="Add" Command="local:Commands.AddTaskCommand"
                          CommandParameter="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type base:PropertyPageBase}},Path=Data}" />

I am getting the error:

System.Windows.Data Error: 4 : Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='Pulse.PLMSuite.Core.Base.PropertyPageBase', AncestorLevel='1''. BindingExpression:Path=Data; DataItem=null; target element is 'MenuItem' (Name=''); target property is 'CommandParameter' (type 'Object')

Is what I want to do possible and if so I'd be grateful for a pointer in the right direction.

Thanks,

Colm