C# 如何在两个类之间创建属性绑定

C# 如何在两个类之间创建属性绑定,c#,binding,C#,Binding,我得到了一个实现INotifyPropertyChanged接口的类vertex。例如,我有两个不同的vertex类实例,我需要将实例a的权重属性绑定到实例b的权重属性 public class Vertex : INotifyPropertyChanged { [...] #region Members <summary> /// Gets or sets the Weight of the vertex //

我得到了一个实现INotifyPropertyChanged接口的类vertex。例如,我有两个不同的vertex类实例,我需要将实例a的权重属性绑定到实例b的权重属性

public class Vertex : INotifyPropertyChanged
{
            [...]
    #region Members
            <summary>
    /// Gets or sets the Weight of the vertex
    /// </summary>
    public int Weight { get { return weight; } set { weight = value; NotifyPropertyChanged("Weight"); } }

    #region INotifyPropertyChanged
            [...]
}
公共类顶点:INotifyPropertyChanged
{
[...]
#区域成员
///获取或设置顶点的权重
/// 
公共整数权重{get{return Weight;}set{Weight=value;NotifyPropertyChanged(“Weight”);}
#区域inotifyproperty已更改
[...]
}

我尝试使用System.Windows.Data.Binding在实例a和b之间创建绑定,但无法设置绑定,因为类vertex上没有SetBinding方法。那么这个问题有没有正确的解决方案呢?

你所说的两个属性之间的绑定是什么意思?你是指例如a.Weight=B.Weight;“例如,你的意思是A.Weight=B.Weight;”是如果A.Weight属性值更改,则属性B.Weight应自动更新。