Two way data Binding for SfAutocomplete in multiple selection mode.

I have created a autocomplete Box with multiple selection mode.

var autocompletelabel = new Label
                        {
                            Text = el.LabelText,
                            Margin = new Thickness(0, 5, 10, 0),
                            TextColor = Color.Black,
                            FontSize = 16,
                            HorizontalOptions = LayoutOptions.Fill,
                            VerticalOptions=LayoutOptions.StartAndExpand
                        };

                        SfAutoComplete autocomplete = new SfAutoComplete {
                            WidthRequest=200
                        };

                        

                        if (!String.IsNullOrEmpty(el.Config))
                        {
                            var config = JsonConvert.DeserializeObject(el.Config);

                            if (config.width != 0)
                                autocomplete.WidthRequest = config.width;
                    
                            if(!String.IsNullOrEmpty(config.Context))
                                    autocomplete.DataSource=getlist(config.Context);

                            if(!String.IsNullOrEmpty(config.MultipleSelect))
                            {
                                if(config.MultipleSelect=="1")
                                {
                                    autocomplete.MultiSelectMode = MultiSelectMode.Delimiter;
                                    autocomplete.Delimiter = ",";
                                }
                                else
                                {

                                }
                            }
                            
                        }

                        
                       autocomplete.DisplayMemberPath = "Label";
                        autocomplete.SelectedValuePath = "Value";
                        autocomplete.SuggestionMode = SuggestionMode.Contains;
                        autocomplete.SuggestionBoxPlacement = SuggestionBoxPlacement.Bottom;
                        autocomplete.ShowSuggestionsOnFocus = true;
                        autocomplete.NoResultsFoundText = "No Results Found";
                        autocomplete.DropDownItemHeight = 45;

                        autocomplete.SetBinding(SfAutoComplete.SelectedItemProperty, string.Format("[{0}]", el.Prop), BindingMode.TwoWay);

Here I am trying the two way Data Binding using SelectedItemProperty. of autocomplete box My SelectedItem is like [{Label="",Value=""},{Label="",Value=""}] this.
Here I have used Dictionary for DataBinding and el.Prop is the key of the Dictionary and it contans the object of [{Label="",Value=""},{Label="",Value=""}] .For the single selection autocomplete this way of Binding is working fine.But for the multiple selection the Binding is not working for object to control and when i am selecting from control the object is getting binded.
Which proerty should i use while using SetBinding(SfAutocomplete.???,"Prop",BindingMode.TwoWay).Can anyone help me how to do this.                      

1 Reply

RB Rabhia Beham Kathar Mideenar Syncfusion Team March 28, 2018 09:37 AM UTC

Hi Shalini,

Thanks for Contacting Syncfusion Support.

We have analysed your requirement and have prepared a sample using SfAutoComplete Control. Please have the sample from the below link.

Sample Link: http://www.syncfusion.com/downloads/support/forum/136690/ze/Autocomplete_3-769839517
 

Please check the sample if it meets your requirement. And regarding the SfListView Items not getting added to the SfAutoComplete Control, we have already fixed the issue and it will be available in Volume 1 Sp 1 Release which is expected to be rolled out by the end of this month.

Regards,
Rabhia Beham K.
 


Loader.
Up arrow icon