Problem with WPF Data Binding Defined in Code Not Updating UI Elements

前端 未结 6 770
天涯浪人
天涯浪人 2021-02-08 22:51

I need to define new UI Elements as well as data binding in code because they will be implemented after run-time. Here is a simplified version of what I am trying to do.

6条回答
  •  無奈伤痛
    2021-02-08 23:35

    The root of it was that the string I passed to PropertyChangedEventArgs did not EXACTLY match the name of the property. I had something like this:

    public int HouseNumber
    {
        get { return _houseNumber; }
        set { _houseNumber = value; NotifyPropertyChanged("HouseNum"); }
    }
    

    Where it should be this:

    public int HouseNumber
    {
        get { return _houseNumber; }
        set { _houseNumber = value; NotifyPropertyChanged("HouseNumber"); }
    }
    

    Yikes! Thanks for the push in the right direction.

提交回复
热议问题