The Path
in a Binding
needs to represent a property. You can create this for your GridControl
by adding a wrapper property to Grid.xaml.cs that just returns the gridControl1
field already created for you because of the x:Name
set in XAML.
public object MyGridControl
{
get { return gridControl1; }
}
CommandParameter="{Binding Path=MyGridControl, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type UserControl}, AncestorLevel=2}}"
You should also consider trying to restructure your application to avoid needing to pass a UI control as a command parameter, especially needing to go outside the local scope as you're doing here. The way it is set up now the controls are very tightly coupled.