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

AutoComplete binding when the source is empty

Source="Custom"

CanResizePopup="False"

MouseLeftButtonDown="autYearFilter_MouseLeftButtonDown"

MouseLeftButtonUp="autYearFilter_MouseLeftButtonDown"

IsFilter="True" StringMode="AnyChar"

HorizontalAlignment="Center"

VerticalAlignment="Center"

MinWidth="100" MaxWidth="100"

Height="30"

Margin="0,0,10,0"

TextChanged="autYearFilter_TextChanged"

CustomSource="{Binding lstYears, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}">


I used AutoComplete as above in my application.

I dynamically bind lstYears ​(list of years) to this autocomplete.

If the lstYears items are updated then, the autocomplete displays the new listitems in the autocomplete. This works fine....

But if lstYears is emptied(no items in this list), the Autocomplete shows the old list items in the autocomplete. I want this autocomplete to be empty when the binding list is empty. How shld that be achieved.


Thanks,

Priya.



1 Reply

BA BagavathiPerumal Apranandham Syncfusion Team April 10, 2023 08:48 AM UTC

Hi Priya,



As AutoComplete is classic control, we suggest you to use the SfTextBoxExt control to achieve your requirements. This is an alternative to AutoComplete control. Please refer to the below-mentioned documentation and the attached sample for your reference.



Documentation link: About WPF Autocomplete control | Syncfusion




Regards,
Bagavathi Perumal A


Attachment: SfTextBoxExt_c204a537.zip

Loader.
Live Chat Icon For mobile
Up arrow icon