I have ComboBox that takes data from another class
public partial class MainWindow : Window
{
private ObservableCollection<MyDataClass> _myList = new ObservableCollection<MyDataClass>();
public MainWindow()
{
InitializeComponent();
comboBox1.DataContext = _myList;
}
private void Button_Click(object sender, EventArgs e)
{
_myList = AnotherClass.SomeMethod();
}
}
The only way to update ComboBox data after button click is to implement INotifyPropertyChanged interface in MyDataClass or there are another ways to do that? I look for another way because MyDataClass is generated from web-service so I need to create some adapter class to implement INotifyPropertyChanged
This is because you’re actually assigning a value to a property, you’re not updating the ObservableCollection.
Thus it needs to be treated as a property, and you have to implement INotifyPropertyChanged.
And by the way, WCF DataContracts automatically implement INotifyPropertyChanged.