Monday 15 February 2010

c# - MVVM TabControl update ComboBox -


I am new to MVVM as a concept and I am currently trying to set things so that To change the index, the item source of a TabControl combo box will be changed to me. I currently have things installed like this:

  public so selected tab index {get {select_selectedTabIndex; } Set {_selectedTabIndex = value; If (_selectedTabIndex == 0) {_readOnlyArray = ReadOnlyArrays.ReadOnlyColumnArrays.LoanerItemsSelect; } And if (_selectedTabIndex == 1) {_readOnlyArray = ReadOnlyArrays.ReadOnlyColumnArrays.CustomerSelect; } And if (_selectedTabIndex == 2) {_readOnlyArray = ReadOnlyArrays.ReadOnlyColumnArrays.JobSelect;   

which is limited to the following of the tab control:

  selected index = "{binding select tabbedx, mode = two}"  < / Ex> 

I also have this:

  public string [] readonline {{back _readOnlyArray; } Set {_readOnlyArray = value}}}   

The combo box is as follows:

  ItemsSource = "{binding readline array, mode = dove} } "  

I know that I am doing this completely wrong but I would like to update the item source of the combobox when the Tab Index of TabControl is changed.

You should notify the interface changing the readOnlyArray after the SelectedTabIndex changes. Assume that the implementation of your visual model INotifyPropertyChanged , you need to set an appropropitive event hander:

 set  {_selectedTabIndex = value; If (_selectedTabIndex == 0) {_readOnlyArray = ReadOnlyArrays.ReadOnlyColumnArrays.LoanerItemsSelect; } And if (_selectedTabIndex == 1) {_readOnlyArray = ReadOnlyArrays.ReadOnlyColumnArrays.CustomerSelect; } And if (_selectedTabIndex == 2) {_readOnlyArray = ReadOnlyArrays.ReadOnlyColumnArrays.JobSelect; } // Your Assistant Method from Base Class Calling // INotifyPropertyChanged.PropertyChanged Event this.RaisePropertyChanged ("ReadOnlyArray"); }   

If it still does not work, then check the VisualStudio output window for any compulsive errors.

No comments:

Post a Comment