Based on your comment. practice following
public class US_State : System.ComponentModel.INotifyPropertyChanged
{
string name;
string abbreviations;
public string Name { get { return name; } set { name = value; RaisePropertyChanged(); } }
public string Abbreviations { get { return abbreviations; } set { abbreviations = value; RaisePropertyChanged(); } }
public event PropertyChangedEventHandler PropertyChanged;
private void RaisePropertyChanged([System.Runtime.CompilerServices.CallerMemberName] string name="")
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
}
}
NOTE: In your case you dont need INotifyPropertyChange for US_State. I added it, if you need 2 way binding in future. You can Create plan properties as you did it
Now you are all set. Create ObservableCollection or List of Us_State in ViewModel (if you are using MVVM). for simplicity I will create List in code behind like
private List<US_State> usStates;
public List<US_State> USStates
{
get
{
return usStates;
}
set
{
usStates = value;
RaisePropertyChanged();
}
}
Now assign USStates = StateArray.states; but make states public in your static class. Now final binding is little bit tricky
As in this example I have declared UsStates in windows/user controls code behind, So you have to guide combobox that bind itemssource to USStates which is placed inside userControl. (Be defauly all content controls looks into datacontext)
have a look of following xaml
<ComboBox Name="cmboTest"
ItemsSource="{Binding USStates, RelativeSource={RelativeSource AncestorType=Window, Mode=FindAncestor}, UpdateSourceTrigger=PropertyChanged}"
DisplayMemberPath="Name" SelectedValuePath="Abbreviations" SelectionChanged="cmboTest_SelectionChanged"/>