How do you bind a ComboBox's SelectedItem to an object that is a copy of an item from ItemsSource?

前端 未结 3 1218
不思量自难忘°
不思量自难忘° 2021-01-02 08:14

I\'m using the MVVM pattern with WPF and have run into a problem, which I can simplify to the following:

I have a CardType model.

public class CardTy         


        
3条回答
  •  一向
    一向 (楼主)
    2021-01-02 08:40

    You can use SelectedValue and SelectedValuePath:

    
    

    Where ProductId is a int property with NotifyPropertyChanged.

    Read a great explanation here: Difference between SelectedItem, SelectedValue and SelectedValuePath

提交回复
热议问题