wpf – 两个自定义依赖项之间的绑定

我有一个在xaml中创建的自定义依赖对象,我想将它的整个实例绑定到另一个自定义依赖对象的属性.控制中发生的一切.
像这样的例子

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;}
}

现在我想将一个行的实例绑定到cell.data属性,也是这样的:

<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/>

任何帮助?

根据需要,这是cell.data的dp属性:

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));

解决方法

现在我得到了你的问题就这样做了

<cell.data>
    <x:Reference Name="row1"/>
  </cell.data>

相关文章

什么是设计模式一套被反复使用、多数人知晓的、经过分类编目...
单一职责原则定义(Single Responsibility Principle,SRP)...
动态代理和CGLib代理分不清吗,看看这篇文章,写的非常好,强...
适配器模式将一个类的接口转换成客户期望的另一个接口,使得...
策略模式定义了一系列算法族,并封装在类中,它们之间可以互...
设计模式讲的是如何编写可扩展、可维护、可读的高质量代码,...