We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

How to set the selectedItems of SfMultiColumnDropDownControl programatically

Hi,

Having a SfMultiColumnDropDownControl with SelectionMode="Multiple".

How can I set the filteredItems after datacontext is already set? I need to iterate through all items of the  SfMultiColumnDropDownControl and check the item, if the item text is in a seperate list(of string).

Thank you.


1 Reply

DM Dhanasekar Mohanraj Syncfusion Team November 18, 2022 03:30 PM UTC

Hi Marco Uffelmann,

We are a little unclear about your scenario. We suspect that your requirement is to set the selected items programmatically. If yes, then it will be achievable by using the SelectedItems property for the SfMultiColumnDropDownControl shown below,

ViewModel.CS:


private ObservableCollection<object> selectedItems;

public ObservableCollection<object> SelectedItems

{

    get

    {

        return selectedItems;

    }

    set

    {

        selectedItems = value;

        RaisePropertyChanged("SelectedItems");

    }

}

public MovieRepositoryViewModel()

{

    MoviesLists = new MovieListRepository();

    selectedItems = new ObservableCollection<object>();

    selectedItems.Add(moviesList[2]);

    selectedItems.Add(moviesList[3]);

    selectedItems.Add(moviesList[4]);

    selectedItems.Add(moviesList[5]);

}


XAML:

<Syncfusion:SfMultiColumnDropDownControl x:Name="MultiColumnControl"

                                                 Width="175"

                                                 Height="25"

                                                 VerticalAlignment="Center"

                                                 ItemsSource="{Binding MoviesLists , Mode=TwoWay , UpdateSourceTrigger=PropertyChanged}"

                                                 SelectionMode="Multiple"

                                                 SelectedItems="{Binding SelectedItems}"

                                                 AllowAutoComplete="True"

                                                 AutoGenerateColumns="False"

                                                 DisplayMember="Title"

                                                 PopupWidth="400"

                                                 ValueMember="Cast" />


Here we have prepared the sample for that please have a look at this. If we misunderstood your requirement, please provide more information regarding the requirement. This would help us to proceed further.

Regards,

Dhanasekar M.


Attachment: SfMultiColumnDemo_e1cb2eda.zip

Loader.
Live Chat Icon For mobile
Up arrow icon