WPF MVVM ComboBox SelectedItem or SelectedValue not working

前端 未结 18 2417
一生所求
一生所求 2020-12-05 06:22

Update

After a bit of investigating. What seems to be the issue is that the SelectedValue/SelectedItem is occurring before the Item source is finis

18条回答
  •  半阙折子戏
    2020-12-05 07:09

    I had the same problem. The thing is. The selected item doesnt know which object it should use from the collection. So you have to say to the selected item to use the item from the collection.

    public MyObject SelectedObject
     {
          get
          {
              Objects.find(x => x.id == _selectedObject.id)
              return _selectedObject;
          }
          set
          {
               _selectedObject = value;
          }
     }
    

    I hope this helps.

提交回复
热议问题