Hey Guys,
I ran into a problem with the SelectedIndices-Property on SfComboBox-Control.
I work with MVVM.
Binding works from ViewModel to View but not the other way around.
XAML:
<comboBox:SfComboBox MultiSelectMode="Token"
TokensWrapMode="Wrap"
IsSelectedItemsVisibleInDropDown="false"
Grid.Row="3" Grid.Column="1"
DataSource="{Binding Groups}"
DisplayMemberPath="GroupName"
SelectedIndices="{Binding SelectedGroups}"
VerticalOptions="Center"
HeightRequest="100">
ViewModel:
public ObservableCollection<OrganisationGroupModel> Groups
{
get => _groups;
set => SetProperty(ref _groups, value);
}
public ObservableCollection<int> SelectedGroups
{
get => _selectedGroups;
set => SetProperty(ref _selectedGroups, value);
}
Model:
public class OrganisationGroupModel
{
public int GroupId { get; set; }
public string GroupName { get; set; }
}
Any ideas, where I'm maybe doing something wrong?
Feature-Suggestion: Bindable SelectedItemsProperty since the Collection is already present in SelectionChangedEventArgs?!
Thanks in advance,
He
|
<combobox:SfComboBox
MultiSelectMode="Token"
TokensWrapMode="Wrap"
IsSelectedItemsVisibleInDropDown="false"
VerticalOptions="Center"
HeightRequest="40"
x:Name="comboBox"
DataSource="{Binding EmployeeCollection}"
DisplayMemberPath="Name"
SelectedIndices="{Binding SelectedGroups, Mode=TwoWay}"/> |
|
private List<int> selectedGroups;
public List<int> SelectedGroups
{
get { return selectedGroups; }
set
{
selectedGroups = value;
this.OnPropertyChanged("SelectedGroups");
}
} |