Custom Search Causing Control to Freeze

2 posts, 0 answers
  1. Andrew
    Andrew avatar
    7 posts
    Member since:
    Dec 2012

    Posted 23 Jan Link to this post

    We are experiencing an issue implementing a custom search on the control. We use MVVM, and have had to adapt the control to get everything wired up. However, on iOS devices only (no emulators) we frequently see the control lock the app up. It doesn'tcrash, just freezes and is unresponsive (I've let it wait for over an hour and it does not unfreeze). Below is the XAML, the code-behind and the method on the ViewModel for the search. Any help would be appreciated, as if we cannot solve the freezing we will have to make use of entry controls instead.

    The XAML:

                                <StackLayout Orientation="Horizontal" HorizontalOptions="Center" Margin="0, 20, 0, 20">
                                    <Label Text="Searching ... " FontSize="16" TextColor="#8E8E93"/>

    The code-behind:
    private string currentSearchText;
    private string previousSearchText;
    private bool isRemoteSearchRunning;
    private bool isSelected = false;
            private async void radACV_TextChanged(object sender, TextChangedEventArgs e)
                if (!isSelected)
                    var autoCompleteView = (RadAutoCompleteView)sender;
                    var vm = (DocSearchViewModel)BindingContext;
                    currentSearchText = e.NewTextValue ?? string.Empty;
                    previousSearchText = e.OldTextValue ?? string.Empty;
                    if (currentSearchText.Length >= autoCompleteView.SearchThreshold && !isRemoteSearchRunning)
                        isRemoteSearchRunning = true;
                        if (autoCompleteView.ItemsSource == null) //if the item source is null, get new
                            autoCompleteView.ItemsSource = await vm.LoadItems(currentSearchText);
                        else if (!currentSearchText.Contains(previousSearchText)) //if the new search text is not a narrowing of the previous text, get new
                            autoCompleteView.ItemsSource = await vm.LoadItems(currentSearchText);
                        isRemoteSearchRunning = false;
                    else if (e.NewTextValue.Length == 0)
                        autoCompleteView.ItemsSource = null;
                        vm.Selected = null;
                        autoCompleteView.ItemsSource = null;
                    isSelected = false;
            private void radACV_SuggestionItemSelected(object sender, SuggestionItemSelectedEventArgs e)
                var autoCompleteView = (RadAutoCompleteView)sender;
                isSelected = true;
                var selectedItem = (ItemModel)e.DataItem;
                var vm = (ViewModel)BindingContext;
                vm.Selected = selectedItem;


    The ViewModel Search function:

    public async Task<List<ItemModel>> LoadItems(string search)
                var items = new List<ItemModel>();
                    IsBusy = true;
                    items = await _dataService.GetItems(search);
                catch (Exception e)
                    IsBusy = false;
                return items;
  2. Nasko
    Nasko avatar
    727 posts

    Posted 28 Jan Link to this post

    Hello Andrew,

    I have tried to reproduce the observed by you freezing using the provided description and code-snippets, but without any luck - it seems everything is working as expected on my side. Attached you can find the sample I have used for my research. Could you please, check it and let me know if I haven't missed something? Modifying and sending me back the sample, so that the freezing you are experiencing could be reproduced will also be of great help for my further investigation.

    I am looking forward to hearing from you.

    Progress Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top