0
主窗口有组合框下面的XAML将图片添加到组合框的值
MainWindowViewModel.xaml
<ComboBox Name="CountryComboBox" HorizontalAlignment="Left" Margin="40,170,0,0" VerticalAlignment="Top" Width="220"
ItemsSource="{Binding Countries, Mode=OneWay}"
SelectedValue="{Binding SelectedCountry, Mode=TwoWay}">
</ComboBox>
MainWindowViewModel.cs
private string _SelectedCountry;
public string SelectedCountry
{
get
{
return _SelectedCountry;
}
set
{
_SelectedCountry = value;
OnPropertyChanged("SelectedCountry");
}
}
public List<string> Countries {get; set;}
public MainViewModel()
{
Countries = new List<string>();
var a = "Avganistan";
var b = "Azerbeijan";
Countries.Add(a);
Countries.Add(b);
}
我如何添加图像这个国家的combobox值?
这是没有必要更换'List'用'ObservableCollection'导致它在ViewModel' – monstr 2014-08-28 09:43:40
的'构造函数初始化,这是没有必要要么执行'INotifyPropertyChanged'接口,但它是很好的做法。 – Sheridan 2014-08-28 09:52:23