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. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to Bind using MVVM?

Thread ID:

Created:

Updated:

Platform:

Replies:

127507 Nov 21,2016 02:14 AM UTC Jul 14,2017 05:00 PM UTC Xamarin.Forms 5
loading
Tags: SfAutoComplete
Emil
Asked On November 21, 2016 02:14 AM UTC

1) I tried your sample codeherein the documentation but it doesnt work. How are supposed to do binding?
2) This tool is only working I think when data is loaded inside constructor of the viewmodel. Once tool appears in the view, It is not possible to bind if even I raise a property changed.

Pavendhan Kumar [Syncfusion]
Replied On November 21, 2016 12:08 PM UTC

Hi Emil,

Thank you for your update.

We would like to know whether you are trying to add AutoCompleteSource dynamically?. Because currently SfAutoComplete did not supports dynamic source updation.

Regards,
Pavendhan K.

Emil
Replied On November 21, 2016 04:03 PM UTC

I tried first dynamically but I guessed that it doesnt work because I experienced from sfrotator. Then i tried like in the documentation. I wrote exactly same code but no chance. Here is my code how I tried it


In xaml I defined AutoComlete as below with the Datasource binding and  Name as DisplayMemberPath

<autocomplete:SfAutoComplete x:Name="autocomplete" Watermark="Enter a name" MinimumPrefixCharacters="3" MaximumDropDownHeight="200" 
                                 AutoCompleteMode="Suggest" SuggestionMode="Contains" DataSource="{Binding AllItems}"  HeightRequest="60" 
                           SelectedValuePath="Id"      DisplayMemberPath="Name">      
    </autocomplete:SfAutoComplete>

In my View Model and its constructor, I get all the items;

  public  class ItemsViewModel
 public ItemsViewModel()
        {
              var Items = await db.getAllItemsAsync(recursive: false);
            AllItems = new ObservableCollection<ItemList>(Items));
            RaisePropertyChanged("AllItems");
            return cacheItems;
        }
}

Then I assign BindingContext in the constructor of the page but it doesnt unfortunately work. I tried using ItemItemSource binding as well but it doesnt work

     autocomplete.BindingContext = new ItemsViewModel();

my Model

     public class Item
    {
        [PrimaryKey, AutoIncrement, Unique, NotNull]
        public int Id { get; set; }

        [MaxLength(255)]
        public string Name { get; set; }
    }

I checked your sample app called "SampleBrowser-Forms" but there example is based on String list not with object list. What am I doing wrong?

Pavendhan Kumar [Syncfusion]
Replied On November 22, 2016 10:20 AM UTC

Hi Emil,

Thank you for your update. We have prepared a sample as per your requirement please download the same from the following link.

Sample Link: http://www.syncfusion.com/downloads/support/forum/127507/ze/AutoCompleteDataSource1218473721 

Please let us know whether the sample meets your requirement or not.

Regards,
Pavendhan K.
 


Nishant
Replied On July 14, 2017 02:19 AM UTC

Request it to make sfautocomplete dynamic... like on user start typing we can go to the server and check for related data.


Thanks 


Vanaja  Annasamy [Syncfusion]
Replied On July 14, 2017 05:00 PM UTC

Hi Emil,

Thank you for the update.

We have created SfAutoComplete sample based on your requirement to add data dynamically using DataSource. Please download the same from below link.

Link:  http://www.syncfusion.com/downloads/support/forum/127507/ze/AutoComplete-564205971 

Please run the sample and check whether it meets your requirement. If not please provide the detailed description of your requirement and it will help us to proceed further with the same.

Regards,
Vanaja R.A. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;