Master
Master

Reputation: 2153

AutoCompleteBox not showing Selected Items

If I select items through the AutoCompleteBox dropdown, it populates the SelectedItems collection but doesn't update the UI. Nothing shows.

For example, my AutoCompleteBox you can currently select between 1-12. If I select [1,2,3] the list will no longer have [1,2,3] but will still have [4-12] to select from and the selected items don't show.

I've set breakpoints to double check and my SelectedItems collection does populate!

I was wondering how do I get the selected items to show.

I think it has to do with the DisplayMemberPath.

<telerik:RadAutoCompleteBox         
    SelectedItems="{Binding MonthsToSkip, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"  
    ItemsSource="{Binding DateAutoCompleteBox, Mode=TwoWay}"/>

.cs:

private List<string> _dateAutoCompleteBox;
public List<string> DateAutoCompleteBox 
{ 
  get { return _dateAutoCompleteBox; } 
  set { _dateAutoCompleteBox = value; OnPropertyChanged("DateAutoCompleteBox"); } 
}

public List<string> MonthsToSkip { get; set; }

Upvotes: 1

Views: 1296

Answers (1)

McGarnagle
McGarnagle

Reputation: 102743

You may need the property to raise PropertyChanged, and/or to be an ObservableCollection:

public ObservableCollection<string> MonthsToSkip 
{ 
    get { return _monthsToSkip; }
    set { _monthsToSkip = value; OnPropertyChanged("MonthsToSkip"); } 
}
public ObservableCollection<string> _monthsToSkip;

Upvotes: 3

Related Questions