i have a custom dependecyobject created in xaml and i would like to bind the whole instance of it to a property of another custom dependecyobject. all that is happening inside a control.
As example something like this
class row : dependencyobject
{
// this is a dp property
public static readonly dependencyproperty widthproperty = dependencyproperty.register...
}
class cell : dependencyobject
{
public static readonly dependencyproperty dataproperty = dependencyproperty.register....
}
class customGridView:Control
{
List<Row>Rows { get;set;}
List<Cell> Cells { get;set;}
}
and now i would like to bind an instance of a row to cell.data property, also something like this:
<customGridView>
<row x:name:row1 width=200/> (this is a class that derives for dependencyobject)
<row .../>
<cell data={Binding ElementName=row1}/> (this is another class that derives from dependencyobj and tries to bind to entire instance of row class)
<cell ..../>
<cell ..../>
</customGridView/>
any help?
as desired this is the dp property of cell.data:
public Row Data
{
get { return (Row)GetValue(DataProperty); }
set { SetValue(DataProperty, value); }
}
// Using a DependencyProperty as the backing store for ColumnName. This enables animation, styling, binding, etc...
public static readonly DependencyProperty DataProperty=
DependencyProperty.Register("Data", typeof(Row), typeof(Cell), new PropertyMetadata(null));
Now I got your Problem do it like this