效果如下:
初始化后根据数据源反显选项,根据操作修改、清空数据源
数据结构
internal class SettingWithComboBoxDemoViewModel : INotifyPropertyChanged
{
public ObservableCollection<FruitViewModel> Fruits { get; set; }
private FruitViewModel selectFruit;
public FruitViewModel SelectFruit
{
get { return selectFruit; }
set
{
if (selectFruit != value)
{
selectFruit = value;
NotifyPropertyChanged(nameof(SelectFruit));
}
}
}
#region INotifyPropertyChanged Members
/// <summary>
/// Need to implement this interface in order to get data binding
/// to work properly.
/// </summary>
/// <param name="propertyName"></param>
private void NotifyPropertyChanged(string p