WPF MVVM ComboBox SelectedItem or SelectedValue not working

前端 未结 18 2365
一生所求
一生所求 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:13

    You can also bind your SelectedIndex to a property in your ViewModel and manipulate your SelectedItem that way:

            public int SelectedIndex
            {
                get { return _selectedIndex; }
                set
                {
                    _selectedIndex = value;
                    OnPropertyChanged();
                }    
            }
    

    And in your XAML:

    
    

提交回复
热议问题