This question is locked. New answers and comments are not allowed.
We are using MVVM. No matter what I do, I cannot get the UI to change when I set the SelectedItem property via the ViewModel. I have tried SelectedItem, SelectedIndex, Text and nothing works for me.
Here is my xaml:
Here is my ItemsSource property which is bound in my xaml:
Here is my SelectedItem property which is bound in my xaml:
Here is my Web Service completed method, where I populate the ItemsSource (which works) and then I try to set the SelectedItem (which doesn't update the UI, but my SelectedItem raise property event does fire)
This problem is driving me absolutely bonkers! I also tried setting up a binding to SelectedIndex, but that doesn't work either. Based on what I have read, I have this set up right. The combo gets the collection and I can change the values via the UI. I just cannot change it via the ViewModel.
Here is my xaml:
<telerik:RadComboBox Width="135" Height="25" Margin="10,0,0,0" DisplayMemberPath="Description" IsEnabled="{Binding GlobalIsEnabled}" ItemsSource="{Binding ComplexionItemsSource}" SelectedItem="{Binding ComplexionSelectedItem, Mode=TwoWay}" Style="{StaticResource RadComboBoxStandard}" />Here is my ItemsSource property which is bound in my xaml:
private ObservableCollection<Complexion> _ComplexionItemsSource = new ObservableCollection<Complexion>();public ObservableCollection<Complexion> ComplexionItemsSource{ get { return _ComplexionItemsSource; } set { _ComplexionItemsSource = value; RaisePropertyChanged("ComplexionItemsSource"); }}Here is my SelectedItem property which is bound in my xaml:
private Complexion _ComplexionSelectedItem;public Complexion ComplexionSelectedItem{ get { return _ComplexionSelectedItem; } set { _ComplexionSelectedItem = value; RaisePropertyChanged("ComplexionSelectedItem"); }}Here is my Web Service completed method, where I populate the ItemsSource (which works) and then I try to set the SelectedItem (which doesn't update the UI, but my SelectedItem raise property event does fire)
private void ComplexionSelectCompletedReturn(object sender, ClientComplexionSelectCompletedArgs e){ if (e.ClientComplexionSelectCompletedResult != null) { foreach (var _Item in e.ClientComplexionSelectCompletedResult) { ComplexionItemsSource.Add(_Item); } if (ComplexionItemsSource.Count > 0) { for (var i = 0; i < ComplexionItemsSource.Count(); i++) { if (ComplexionItemsSource[i].IsDefault) { ComplexionSelectedItem = ComplexionItemsSource[i]; } } } }}This problem is driving me absolutely bonkers! I also tried setting up a binding to SelectedIndex, but that doesn't work either. Based on what I have read, I have this set up right. The combo gets the collection and I can change the values via the UI. I just cannot change it via the ViewModel.