AutoComplete Binding Mode does not default to TwoWay in the property SelectedItem

Hello,

I believe this is a bug on the control as I expected it to default to TwoWay (although I may be wrong). Here is the XAML:

...xForms:SfAutoComplete ...
   DataSource="{Binding SomeListOfObject}"
   SelectedItem="{Binding SomeObject}"
   DisplayMemberPath="Name"
   >

After selecting an item in the control, I read the property SomeObject in my view model and it is null.

Whereas with this XAML it works fine:

...xForms:SfAutoComplete ...
   DataSource="{Binding SomeListOfObject}"
   SelectedItem="{Binding SomeObject, Mode=TwoWay}"
   DisplayMemberPath="Name"
   >
EDIT: It looks like there are other problems with SelectedItem. For example, after I select one item from the list, if I assign null to SelectedItem it does not clear the text on the control. I am doing this in the view model, not directly. For the moment I resorted to setting the Text to empty in the code behind but it would be cleaner if I could do everything from the view model.

Thanks,
Jose

P.S. The forum deleted some of the XAML.


8 Replies

SK Selva Kumar  Veerakrishnan Syncfusion Team February 19, 2018 12:15 PM UTC

Hi Jose,

Thank you for contacting Syncfusion Support.

Query: TwoWay Binding mode for SelectedItem Property in SfAutocomplete.

Currently in SfAutoComplete the selectedItem property is in BindingMode.Default. We will fix this with TwoWay and this fix will be included in our upcoming Volume 1 service pack 1.

Query: after I select one item from the list, if I assign null to SelectedItem it does not clear the text on the control

We could reproduce this issue “updating SelectedItem to null does not clear the text inside the control”. This fix will also be included in our upcoming Volume 1 service pack 1, which is expected to be rolled out by the end of March.

Regards,

Selva Kumar V.


SK Selva Kumar  Veerakrishnan Syncfusion Team February 19, 2018 01:53 PM UTC

Hi Josh,

Please ignore the previous update for “Query: after I select one item from the list, if I assign null to SelectedItem it does not clear the text on the control“.

When our SfAutoComplete dropdown items get selected, the selected item will be displayed inside the SfAutoComplete text box. Our current behaviour is during runtime when the SelectedItem becomes null, the Property alone will get null, the AutoComplete text remains the same as previously selected item. Reason for this behaviour: Since our SfAutoComplete control is an editable control, user can continue with the pre-existing text to find the next possible search. So that if the SfAutoComplete text box has to become empty, user has to set the text as empty manually.

We would like to know more information on this, whether the AutoComplete text property has to become null when the SelectedItem is set to null at run time. This will be more helpful for us to provide better solution on this.

Regards,

Selva Kumar V.


JO Jose February 20, 2018 02:14 PM UTC

Hello,

Thanks for the answers. Regarding setting the SelectedItem: I understand your explanation but I have this screen (backed by a view model) which contains a few SfAutoCompletes and it has a Clear button. When the user presses the Clear button I need to delete the Text of all the entries to reset the form. I even tried setting the Text property to string.Empty in the code behind but that also fails (the Text property is blank but the screen is not updated) so I am stuck, unable to implement this feature. I would be very happy if you can come up with a solution for this one.

Thanks,
Jose


SK Selva Kumar  Veerakrishnan Syncfusion Team February 21, 2018 01:08 PM UTC

Hi Jose,

Thanks for your response.

We can clear the text inside the SfAutoComplete TextBox by using String.Empty or by using Clear() method in SfAutoComplete. We have prepared a sample for your requirement, in which we have placed a set of 5 AutoComplete, when we pressed the “Click to delete” button the text inside the AutoComplete text box will get cleared also we have recorded a video for the same output. Please download the sample and video from the link given below.

Sample link: https://www.syncfusion.com/downloads/support/directtrac/general/ze/SFAutoComplete_7-1845114881.zip

Video link: https://www.syncfusion.com/downloads/support/directtrac/general/ze/AutoCompleteClear-1792477290.zip

If you could reproduce the issue at your end, please update us with the modified sample along with the replication steps. In addition to that please let us know the the Syncfusion Essential Studio version which you have used at your end. This could help us to provide better solution on this.

Regards,

Selva Kumar V.


JO Jose February 23, 2018 02:24 PM UTC

Many thanks Selva. I will look into your sample ASAP and will come back with an update.

Jose


RB Rabhia Beham Kathar Mideenar Syncfusion Team February 26, 2018 06:56 AM UTC

Hi Jose,

Thanks for your response. We will wait to hear from you. 
Regards,
Rabhia Beham K.
 




JO Jose February 26, 2018 09:41 AM UTC

Hi,

Yes, calling Clear instead of setting Text to empty string solved the problem.

Many thanks,
Jose


RB Rabhia Beham Kathar Mideenar Syncfusion Team February 27, 2018 07:37 AM UTC

Hi Jose,

Thanks for the response.

Please let us know if you need any further assistance on this. 
Regards,
Rabhia Beham K. 


Loader.
Up arrow icon