属性设置器未调用数据绑定属性

时间:2009-08-24 15:32:11

标签: c# data-binding

我有一个绑定到自定义对象的组合框。大多数情况下,以下代码不会设置自定义对象(但有时会这样做)。你对这个问题有任何线索吗?

     //In the main form
     _person = new Person();
     _citySelector.DataBindings.Add("SelectedCity", _person, "Adress.City"); //Adress is an object, city too
   .------------------
    //A property of _citySelector (city selector derives from UserControl and implements INotifyPropertyChanged )
    public City SelectedCity 
    {
        get { return ultraComboCities.SelectedRow.ListObject as City;}
        set
        {
            //Horrible but there is no selector.SelectedValue = 
            foreach (UltraGridRow row in ultraComboCities.Rows)
            {
                if(row.ListObject as City == value)
                {
                    ultraComboTiers.SelectedRow = row;
                    RaisePropertyChanged("SelectedCity");
                    return;
                }
            }
        }
    }
.------------------ 
    //I call the following code on my city select object 
    //(1)
    SelectedTier = City.Get("London"); //ultraComboCities was first populated with cities object including London

在(1)的电话之后,_person.Adress.City(大部分时间)都没有刷新......

0 个答案:

没有答案