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
close icon

Type od selecteditems

Hi

wihich kind of type should  i pass to the SelectedItem property?

Is "List<string>" the correct type?

I receive the exception that the object does not implement IConvertible

Then i would like use on that property a foreach to use value changed form the user

Best regards
Alberto C.



6 Replies

HM Hemalatha Marikumar Syncfusion Team October 25, 2019 06:48 AM UTC

Hi Alberto,

Greetings from Syncfusion. 
 
Query: Which kind of type should I pass to the SelectedItem property? 
 
We would like to let you know that Type of SelectedItem property is object. Hence it holds a single item for single selection (MultiSelection Mode – None) and collection of items for multi selection (MultiSelectiion Mode – either Token or Delimiter). 
 
You can retrieve the SelectedItem from ValueChanged event also. Please download the prepared sample in below 
Query: Is "List<string>" the correct type?  
 
As mentioned above, it will be correct type of assigning to the SelectedItem with MultiSelectionMode of either in Token or Delimiter.

UG Linkhttps://help.syncfusion.com/xamarin/sfcombobox/retrieving-selected-values?cs-save-lang=1&cs-lang=csharp#selecteditem

Please check with the above sample and let us know if you have any concerns.

 
Regards, 
Hemalatha M. 



AL Alberto October 25, 2019 09:27 AM UTC

I have tried with an observable collection but  when i arrive on this line of code

  EmailTo = new ObservableCollection<object>();

the application stay in pause , the screen stays frized

This is the piece of code in the xaml

 
                    <sfComboBox:SfComboBox DataSource="{Binding ListEmailTo}"
                                           SelectedItem="{Binding EmailTo}"
                                             MultiSelectMode="Token" TokensWrapMode="Wrap"             
                                               ClearButtonColor="{StaticResource Primary}"
                                               TextColor="{StaticResource PrimaryText}"
                                               DropDownTextColor="{StaticResource PrimaryText}"
                                               DropDownBorderColor="{StaticResource Primary}"                                               
                                               IsSelectedItemsVisibleInDropDown ="False">
                        <sfComboBox:SfComboBox.TokenSettings>
                            <sfComboBox:TokenSettings BackgroundColor="{StaticResource Primary}" TextColor="White"                                                                                                                    
                                                          IsCloseButtonVisible="true" 
                                                          DeleteButtonColor="{StaticResource PrimaryDark}">
                            </sfComboBox:TokenSettings>
                        </sfComboBox:SfComboBox.TokenSettings>
                    </sfComboBox:SfComboBox>


in the code properties are set in this way 

private ObservableCollection<object> _EmailTo;

        public ObservableCollection<object> EmailTo
        {
            get { return _EmailTo; }
            set { SetProperty(ref _EmailTo, value); }
        }

        private ObservableCollection<object> _ListEmailTo;

        public ObservableCollection<object> ListEmailTo
        {
            get { return _ListEmailTo; }
            set { SetProperty(ref _ListEmailTo, value); }
        }

and the piece of code when i set the variables is this

foreach (var item in invioEmailToInfo.Item1.ToList())
            {
                ListEmailTo.Add(item.Email);
            }
            
            EmailTo = new ObservableCollection<object>();

            foreach (var item in invioEmailToInfo.Item2.Split(Convert.ToChar(",")))
            {
                EmailTo.Add(item);
            }

Xamarin version 4.2.0.910310
Syncfusion.Xamarin.SfComboBox 17.3.0.19

Best Regards
Alberto C.



HM Hemalatha Marikumar Syncfusion Team October 28, 2019 08:55 AM UTC

Hi Alberto,

Thanks for the update.

We have prepared the sample based on your provided code examples. Unfortunately, we were unable to reproduce the same. Please find the tested sample in below, 
 
Sample Link
https://www.syncfusion.com/downloads/support/directtrac/general/ze/CO8E99~1-938106393

If the issue mentioned differs from the above please modify the provided sample with the issue reproducing sample and also the platform details and please confirm whether the ComboBox is placed inside the SfTextInputLayout which will be helpful for us to analyze further and provide an appropriate solution. 
 
Regards, 
Hemalatha M. 



AL Alberto October 28, 2019 11:03 AM UTC

Hi,

i have tested more with this control and i have noticed that, if in the constructor i set the collection i don't have any problem to see the list otherwise iif i am in a separate thread the item source is  not set correctly.


Usually after the constructor we start a parallel thread in order to load collection

await (page.BindingContext as ViewModelBase).InitializeAsync(parameter);         

With other component's we have not found any issue.

Best regards
Alberto C.



HM Hemalatha Marikumar Syncfusion Team October 30, 2019 11:51 AM UTC

Hi Alberto,

Thanks for the update.
 

We have checked your requirement “Load the DataSource and SelectedItems with Async” in SfComboBox. We have prepared the sample based on your requirement.
 
  
Sample Link: 
  
Video Link: 
  
If your requirement is different from above, please let us share more details with modified sample which will more helpful to check the reported issue and provide a better solution. 
 
Regards, 
Hemalatha M. 



HM Hemalatha Marikumar Syncfusion Team October 30, 2019 12:13 PM UTC

Hi Alberto,

Thanks for the update.
 

We have checked your requirement “Load the DataSource and SelectedItems with Async” in SfComboBox. We have prepared the sample based on your requirement.
 
  
Sample Link: 
  
Video Link: 
  
If your requirement is different from above, please let us share more details with modified sample which will more helpful to check the reported issue and provide a better solution. 
 
Regards, 
Hemalatha M. 


Loader.
Live Chat Icon For mobile
Up arrow icon