Frenchi In LA
Frenchi In LA

Reputation: 3169

Silverlight RadComboBox keeping open after selection

Silverlight MVVM. I have a RadCombobox, and for each selection I'm adding a new row in another datagrid. I add necessaries codes in my ViewModel class and this part is working. What I’d like to perform is:

  1. Keep the comboBox open while the control has the focus in order to allow the user repeating selection (I bind IsDropDownOpen to a method and setting in SelectedItem property to true but still it closes after selection )

  2. Unselect the Item selected to allow duplication selection. I added the event SelectionChanged and add code in MainPage.xaml.cs but looking for a solution within my ViewModel.

Upvotes: 4

Views: 734

Answers (1)

Jugal Thakkar
Jugal Thakkar

Reputation: 13472

Lets say,

  IsDropDownOpen = {Binding IsDropDownFromViewModel}

Also, assuming that the getter of IsDropDownFromViewModel is encompassing all your conditions for the drop down to be open, and will always return the correct drop down state.

Now all that you will need to do is fire the PropertyChanged event for this property wherever/whenver you think the drop down should have been open, but is closed, or vice versa.

Unfortunately I didn't get your exact scenario, but lets assume this is the case (You should be use a similar approach to fix whatever problem you have).

Example Scenario:

The drop down closes when you select an item, it is intended to stay open

In the above case, one the user selects an item, the setter for the selectedItem's corresponding binding property should be invoked, so that is where we write the notification code

  public SelectedItemType SelectedItemInViewModel {
    get{ 
     return _selectedItemVM; 
   },
   set{
     _selectedItemVM=value;
     NotifyPropertyChanged("IsDropDownFromViewModel");
   }
 }

What this does is, it will tell the radComboBox's IsDropDownOpen property to reevaluate it's binding expression on the RHS and get its new value

Hope you get the gist of the approach, if not leave a comment.

Upvotes: 1

Related Questions