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.
Unfortunately, activation email could not send to your email. Please try again.

Setting the valuechanged propertyin XAML generates error

Thread ID:

Created:

Updated:

Platform:

Replies:

129990 Apr 13,2017 08:00 AM Apr 14,2017 07:35 AM Xamarin.Forms 2
loading
Tags: SfAutoComplete
Guy Lemire
Asked On April 13, 2017 08:00 AM

Hello,I am trying to bind the valuechanged event to a function in the viewmodel to retrieve data from a database to populate the autocomplete control, I am working on a portable app, currently I am building for IOS only, but I will need to work with Android soon. When I add the valuechanged to the XAML I get the following error Unable to cast object of type 'Xamarin.Forms.Xaml.ElementNode' to type 'Xamarin.Forms.Xaml.ValueNode'. 

The XAML Code: 
<autocomplete:SfAutoComplete x:Name="documentSearch" 
                                             DataSource="{Binding Items}" 
                                             HeightRequest="40" 
                                             WidthRequest="150"
                                             Watermark="Enter document #..."
                                             SelectedValuePath="value" 
                                             DisplayMemberPath="text" 
                                             SuggestionMode="Contains"
                                             ValueChanged="{Binding SearchCommand}"  />

Any help on getting this to work would be appreciated.

Thank you

Guy Lemire
Replied On April 13, 2017 10:13 AM

Ok,
I think I need to take a break, I was looking at my code and the issue is the Syncfusion does not allow the autocomplete to bind to a command, I had to do a work around that I found to be hackish and not quite in keeping with the MVVM model.

in the code behind I had to create the event handler and then call the MVVM object. 

private void DocumentSearch_ValueChanged(object sender, Syncfusion.SfAutoComplete.XForms.ValueChangedEventArgs e)
        {
            var vm = new ViewModel();

            documentSearch.DataSource = vm.searchDocuments(e.Value);
        }
It would be great if the controls could bind to the MVVM command.


Chozarajan Pandiyarajan [Syncfusion]
Replied On April 14, 2017 07:35 AM

Hi Guy Lemire,

Thanks for contacting syncfusion support.

We have checked your reported issue "Command binding is not working with SfAutoComplete Valuechanged event". In our current implementation, we do not have support for command binding for value changed event in SfAutocomplete. So, we have considered it as a feature request and it will be available in any of our upcoming release. Meanwhile we have created a workaround for this issue. In this workaround, we have created behavior for SfAutocomplete and invoked valuechanged event in that behavior. Please find the sample from below

Sample: Command_Sample
  
Regards,
Chozarajan P  


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.

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.

;