Form not showing after adding autocomplete control

Posted by: stevecarmichelle1 on 4 January 2018, 10:51 pm EST

  • Posted 4 January 2018, 10:51 pm EST

    Hi,

    I am using Autocomplete control in a content page in Xamarin forms. I have done everything to generate the license and add it to the App.xaml.cs file.

    But when calling the page that hosts the autocomplete control, I am getting this error

    " Warning: Attempt to present <Xamarin_Forms_Platform_iOS_ModalWrapper: 0x7fcdc6444a50> on <Xamarin_Forms_Platform_iOS_PlatformRenderer: 0x7fcdc663a300> whose view is not in the window hierarchy!"

    The autocomplete control is placed in a Content Page that has a Navigation Bar.

    I tested the control in a stand alone project as per your examples and it loads but I see the reminder dialog every time the project starts. But I am not seeing the reminder dialog for my existing project after adding the Autocomplete control.

    What is the reason for this unexpected error. The project was working fine before adding the ComponentOne AutoComplete control and the nuget packages. I would be grateful if you could assist in this.

    I would like to know if this control as the property to append or suggest values as the user keeps typing and the closest match is found.

    Thanks,

    Rajesh

  • Posted 5 January 2018, 2:36 am EST

    Hi Rajesh

    I’m not sure what the issue is exactly, but that warning points towards some problem presenting a Xamarin.Forms page modally on iOS, and it doesn’t appear to be an issue with the AutoComplete directly. If your shared project I might be able to say something more specific.

    As for the AutoComplete, it will make suggestions based on whatever data is supplied to the ItemsSource of the control as a list of possible suggestions. This can be something relatively narrow (like a list of supplied countries as you see in our samples), or something more broad like the dynamic AutoComplete which uses YouTube to provide suggestions based on dynamic search results.

    Thanks

    Kelley

  • Posted 7 January 2018, 2:19 pm EST

    Hi

    Thanks for your reply. I noticed that the project was working fine before adding the nuget packages for Autocomplete.

    The moment, I add the nuget packages for C1.Xamarin.Forms.Input and this line of code

    C1.Xamarin.Forms.Input.Platform.iOS.C1InputRenderer.Init();

    the navigation to the page where the autocomplete control is hosted is no longer working.

    Here is the sample code that calls the page which does not show.

    			```
    

    var cmm = new CMainMenu();

    			NavigationPage.SetHasNavigationBar(cmm, true);
    
    			NavigationPage.SetHasBackButton(cmm, false);
    
    			NavigationPage.SetBackButtonTitle(cmm, "");
    
    			NavigationPage.SetTitleIcon(cmm, "");
    
    			//NavigationPage.
    
    			NavigationPage mypagecmm = new NavigationPage(cmm);
    
    
    I have even added this line of code 
    
    

    C1.Xamarin.Forms.Core.LicenseManager.Key = “AB4BHgIeB4ZUAGkAYwBrAGUAdAB3AG8AcgBrAHM…”;

    
    Can you please let me know if the reminder dialog that appears when firing up the project is the reason for it. How can I suppress the alert every time I launch the application.
    
    I created a single page application with this control and it works fine. And I think that the display alert that appears is the reason for this failure in my application that has multiple pages and a Navigation bar.
    
    #2. Regarding the suggestions in the drop down, I wanted to know if this control supports filtering "Starts with" because I would like to have that option too and it helps the user to find his choices easier than the clause "Contains."
    
    Thanks,
    
    Rajesh.
  • Posted 7 January 2018, 2:56 pm EST

    Hi,

    I am able to reproduce this behavior with a sample project. Attaching the same for your analysis.

    Launch the application. You will see the button login. Click that. Nothing happens.

    Now go to the page App.xaml.cs

    Change the startup page from login to SimpleAutoCompletePage and notice the difference.

    When the startup page is the page that has the ComponentOne control it works fine. but when trying to navigate to a page that has the ComponentOne control it fails to launch.

    Kindly let me know how to fix this issue, since I am evaluating your controls for my Xamarin project.

    Attaching the project as a zip file. Please note that it was developed in Visual Studio for Mac.

    Thanks

    Rajesh.

    SimpleAutoComplete.zip

  • Posted 8 January 2018, 3:31 am EST

    Hi Rajesh

    Thank you for the sample. It actually runs fine for me under Visual Studio 2017 on PC and Visual Studio for Mac. While I see the warning you mentioned it doesn’t seem to lead to any actual crash or issue with the page. Maybe it’s a matter of running updates on VS for Mac and Xcode, but I can’t reproduce the issue here.

    Thanks

    Kelley

  • Posted 8 January 2018, 3:45 am EST

    Hi

    Can you please specify the versions of VS for Mac, the Xamarin libraries, and any related version information so that I can check with my version.

    I will try to check if it works in Visual Studio on Windows.

    Thanks,

    Rajesh.

  • Posted 8 January 2018, 8:06 am EST

    Hi Rajesh

    On Mac:

    === Visual Studio Enterprise 2017 for Mac ===

    Version 7.3.2 (build 12)

    Installation UUID: 5740f803-436a-492e-95db-4c59f59239bf

    Runtime:

    Mono 5.4.1.7 (2017-06/e66d9abbb27) (64-bit)

    GTK+ 2.24.23 (Raleigh theme)

    Package version: 504010007

    === Xamarin.iOS ===

    Version: 11.6.1.2 (Visual Studio Enterprise)

    Hash: 6857dfcc

    Branch: xcode9.2

    Build date: 2017-12-04 21:20:41-0500

    === Apple Developer Tools ===

    Xcode 9.2 (13772)

    Build 9C40b

    On PC:

    Microsoft Visual Studio Enterprise 2017

    Version 15.5.2

    VisualStudio.15.Release/15.5.2+27130.2010

    Microsoft .NET Framework

    Version 4.7.02556

    Xamarin 4.8.0.753 (6575bd113)

    Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

    Xamarin.iOS and Xamarin.Mac SDK 11.6.1.2 (6857dfc)

    Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.

  • Posted 9 January 2018, 8:42 pm EST

    Hi,

    Thanks a lot for this valuable help, After updating Visual Studio for Mac with the latest versions, everything worked fine. I evaluated and experimented with the Auto Complete control in my project and found some behavior that was different from what we expect.

    Please find my queries below with the attached project to demonstrate the strange behavor.

    1. Why is the ForceAbove or ForceBelow not working. First time it pop ups above the control. Second time it is below as usual and it is hidden by the keyboard.

    2. If the screen scrolls when the keyboard popups the drop down is detached. Can it be fixed to the control so that both move up scrolling

    3. DropDownWidth not working. I want to increase the width if the control width is small. Enable the user to see the full text when scrolling. For example i adjust the width of the control to 75 which is very small, I expected the width of the dropdown to be more than 75 so that the user could see the entire width of the rows and select one. In spite of setting the width of the drop down to more than the width of the control it does not work. Please let me know in what scenarios does DropDownWidth work and what benefit does it give.

    4. Is there no option to erase the selected item (placing a X mark that is seen when the control is in Default Mode (fills the whole screen) when using the other options apart from Default.

    5. I would like to show the drop down to filter the data based on “Starts with”. This is because most users will be hoping to see the words starting with the first few characters that he enters. But it is showing the filter as “Contains” and the user needs to scroll to see the words starting with the first character that he enters.

    Kindly let me know how to improve the functionality of the Autocomplete control and fix the issues explained above.

    Scenarios to show the issues as explained.

    Tap the control Seven. The drop down apppears below it. Scroll the screen up and it should make the dropdown move up also. But that doesnt happen.

    Tap the control Ten. I am unable to see where the cursor is so that I can type the first few characters.

    Tap the control Nine. the popup appears above. Select a word. Delete the word using the backspace. Tap it agian. now the dropdown appears below.

    Tap the control Ten. the popup appears hiding the control. Using the keyboard enter a character. Now the drop down adjusts so that the entry is seen but the popup appears below.

    Thanks,

    Rajesh.SimpleAutoComplete.zip

  • Posted 17 January 2018, 1:02 am EST

    Hi,

    Has anyone from the support/product team looked into the bugs I mentioned above. Is there any resolution for the same.

    Please reply at the earliest with a feasible solution for all the issues.

    Thanks,

    Rajesh.

  • Posted 17 January 2018, 6:42 am EST

    Hi Rajesh

    1. I was able to reproduce this on Android, but not the other platforms. I’ll add the bug to be fixed.
    2. This will be addressed in an upcoming hotfix.
    3. I think there’s a bug on iOS and Android. There shouldn’t be a limitation.
    4. There isn’t anything in the control that supports this right now, but we’ll consider this as an enhancement in the future.
    5. The control doesn’t directly have a setting for this. The ItemsSource is CollectionView based so there might be a way to enable this functionality, but I’m not sure how complete it will be. I’ll do some more research.
  • Posted 17 January 2018, 8:02 am EST

    Hi Rajesh

    For point 5, you should be able to use the Filtering event of the AutoComplete to perform a custom filter for StartsWith:

    
    private async void OnCustomFiltering(object sender, AutoCompleteFilteringEventArgs e)
    {
        var autoComplete = sender as C1AutoComplete;
        var deferal = e.GetDeferral();
        try
        {
            await autoComplete.CollectionView.FilterAsync("Name", FilterOperation.StartsWith, e.FilterString);
            e.Cancel = true;
        }
        finally
        {
            deferal.Complete();
        }
    }
    

    One note about that, though it will change the filtered list that appears in the dropdown, it does not change the highlighting algorithm for the control (which is based around highlighting any occurrence of the letter) so you may way change the highlighted text color to match the regular text color.

    Thanks

    Kelley

  • Posted 26 January 2018, 2:23 am EST

    Hi Rajesh

    Issue to you mentioned where the control dropdown detaches when placed in a ScrollView on iOS has been fixed in build 2.5.20173.241 which is now live on nuget.org. The other issues you mentioned are still outstanding.

    Thanks

    Kelley

  • Posted 26 January 2018, 7:18 am EST

    Also, I forgot to mention this earlier, but we should be able to support improved filter customization in build 241. If you wanted to implemented StartsWith with custom highlighting, you could use the OnItemLoading event:

    private async void OnCustomFiltering(object sender, AutoCompleteFilteringEventArgs e)
    {
        var autoComplete = sender as C1AutoComplete;
        var deferal = e.GetDeferral();
        try
        {
            await autoComplete.CollectionView.FilterAsync("Name", FilterOperation.StartsWith, e.FilterString);
            e.Cancel = true;
        }
        finally
        {
            deferal.Complete();
        }
    }
     
    private void OnItemLoading(object sender, ComboBoxItemLoadingEventArgs e)
    {
        var autoComplete = sender as C1AutoComplete;
        var label = new Label();
        var name = (e.Item as Country).Name;
        var formattedString = new FormattedString();
        formattedString.Spans.Add(new Span() { Text = name.Substring(0, autoComplete.FilterString.Length), FontAttributes = FontAttributes.Bold });
        formattedString.Spans.Add(new Span() { Text = name.Substring(autoComplete.FilterString.Length) });
        label.FormattedText = formattedString;
        e.ItemView = label;
    }
     
    
  • Posted 28 January 2018, 10:41 pm EST

    Hi,

    Thanks for the update, Will update the nuget components in my application and test this. And please let me know when the other issues have been fixed in a future build.

    Thanks,

    Rajesh.

  • Posted 7 February 2018, 7:41 pm EST

    Hi,

    Any updates on the fixing of the remaining bugs. when can we see the next build with complete functionality on both platforms Android and iOS.

    Thanks,

    Rajesh.

  • Posted 9 February 2018, 1:13 am EST

    Hi Rajesh

    I don’t have any updates at this point. We’re working towards on the 2018 v1 release which should be next month. It’s possible that some of this could fit into the bug fixes in that release, but it’s still a bit premature at this point to say anything. I’ll update you when we get closer if there are fixes for these particular issues.

    Kelley

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels