This will have been answered in the other numerous threads on databinding and implementing INotifyPropertyChanged. However, I am still have difficulty getting this to work.
Essentially I have two listboxes, when the user selects the server name from the first listbox the second is supposed to provide a list of databases on that server. Pretty simple. The second listbox however is not displaying the updated list of databases.
Here is the code: Code to exec query and add data to the DatabaseList property.
private void selection_Server_SelectionChangeCommitted(object sender, EventArgs e)
{
server = (string)selection_Server.SelectedItem;
try
{
ExecDBList(server, ref vm);
}
Class that manages properties used on the window.
public class VM : INotifyPropertyChanged
{
private static List<string> _dblist;
public List<string> DatabaseList
{
get
{
return _dblist;
}
set
{
if (_dblist != value)
{
_dblist = value;
};
}
}
public VM() { }
void OnPropertyChanged(string PropertyName)
{
PropertyChanged(this, new PropertyChangedEventArgs(PropertyName));
}
public event PropertyChangedEventHandler PropertyChanged;
Code line on MainWindow initialization that assigns the listbox DataSource
selection_RDM.DataSource = vm.DatabaseList;
Any help in getting this to work would be much appreciated as I'm struggling to understand the previous answers to databinding and using PropertyChangedEventHandler.
Thank you Richard