I have a view model & a System Windows Form with a couple of list boxes
I have bound data to the contents of the list box, as below
When user interacts with box one, it updates the view model to change contents of box two
When open and close form, all is well - boxes show the right contents
I have implemented OnPropertyChanged to confirm that the view model also updates correctly
However, I have as yet failed to make the second box refresh its contents in response to OnPropertyChanged, until I close and open the form
I've tried calling form.refresh() as well as the checklistbox.refresh() after notification that the the updating function has completed
One thing I did notice was that changing the contents of the object the view is bound to didn't fire OnPropertyChanged, which I thought was odd. It only changes when the object is initialised? Am I doing something wrong there?
protected override void OnBindingContextChanged(EventArgs e)
{
base.OnBindingContextChanged(e);
Globals.ThisAddIn.TFSTeamsViewModel.PropertyChanged += OnPropertyChanged;
}
void LoadProjectsListBox()
{
try
{
Globals.ThisAddIn.TFSConfigViewModel.LoadListOfProjectsIntoFormControl();
projects_list_box.DataSource = Globals.ThisAddIn.TFSConfigViewModel.ListOfProjectsFromVM.value;
projects_list_box.DisplayMember = "name";
Globals.ThisAddIn.TFSTeamsViewModel.LoadTeamsForProjectsChosen();
teams_checked_list_box.DataSource = Globals.ThisAddIn.TFSTeamsViewModel.ListOfTeamsFromVM.value;
teams_checked_list_box.DisplayMember = "name";
SelectCheckBoxForSavedSelection();
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine("Debug: TFS_Config_UI_Control: LoadProjectsListBox: Exception: " + ex.Message);
}
}