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

Setting the valuechanged propertyin XAML generates error

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

2 Replies

GL Guy Lemire April 13, 2017 02:13 PM UTC

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.



CP Chozarajan Pandiyarajan Syncfusion Team April 14, 2017 11:35 AM UTC

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  


Loader.
Live Chat Icon For mobile
Up arrow icon