I'm rather new to MVVM as a concept and I'm currently trying to set things up so that changing the selected index of a TabControl will change the item source of a ComboBox I have. Currently I have things set up as follows:
public int SelectedTabIndex
{
get
{
return _selectedTabIndex;
}
set
{
_selectedTabIndex = value;
if (_selectedTabIndex == 0)
{
_readOnlyArray = ReadOnlyArrays.ReadOnlyColumnArrays.LoanerItemsSelect;
}
else if (_selectedTabIndex == 1)
{
_readOnlyArray = ReadOnlyArrays.ReadOnlyColumnArrays.CustomerSelect;
}
else if (_selectedTabIndex == 2)
{
_readOnlyArray = ReadOnlyArrays.ReadOnlyColumnArrays.JobSelect;
}
}
Which is bound to the following of a TabControl:
SelectedIndex="{Binding SelectedTabIndex, Mode=TwoWay}"
I also have this:
public string[] ReadOnlyArray
{
get { return _readOnlyArray; }
set { _readOnlyArray = value;}
}
Which is bound to a ComboBox as follows:
ItemsSource="{Binding readOnlyArray, Mode=TwoWay}"
I know most likely I'm doing this completely wrong but I'd like the ComboBox's item source to update whenever the tab index of the TabControl is changed.
ReadOnlyArraywhen it defines a public setter? - PoweredByOrange