RadAutoCompleteBox with dynamic ItemSource problem.

3 posts, 1 answers
  1. Bryan
    Bryan avatar
    2 posts
    Member since:
    Feb 2014

    Posted 18 Feb Link to this post

    I have an RadAutoCompleteBox with a dynamic ItemSource that works some places and not others.  In the setter for the SearchText I run a search and populate the ItemSource.  In the box I'm working on now, the ItemSource's ObservableCollection is giving me "Exception thrown: 'System.ArgumentException' in System.Core.dll" when i try and add item to it. This method works many places elsewhere, and If i manually set the SearchText elsewhere the offending code runs without error. Any help would be greatly appreciated.

    Here's the XAML:

    <telerik:RadAutoCompleteBox 

        Grid.Column="2" Grid.Row="3"
        x:Name="AutoCompleteBoxMakeModel"
        ItemsSource="{Binding MakeModelCollection}"
        SearchText="{Binding MakeModelTerm, Mode=TwoWay}"
        SelectedItem="{Binding SelectedMakeModel, Mode=TwoWay}"
        SelectionMode="Single"
        HorizontalAlignment="Left" 
        TextSearchPath="Display"
        TextSearchMode="Contains"
        AutoCompleteMode="Suggest"
        IsDropDownOpen="{Binding IsMakeModelDropDownOpen, Mode=TwoWay}"
        DropDownItemTemplate="{StaticResource MakeModelSearchTemplate}"
        DropDownWidth="300"
        VerticalAlignment="Top" Width="275"  Height="25" Margin="0,3,0,0" >
        <telerik:StyleManager.Theme>
            <telerik:VisualStudio2013Theme/>
        </telerik:StyleManager.Theme>
    </telerik:RadAutoCompleteBox>

     

    And here's the offending code:

    private string makeModelTerm;
    public string MakeModelTerm
    {
        get { return makeModelTerm; }
        set
        {
            if (makeModelTerm == value)
            {
                return;
            }
            makeModelTerm = value;
            RaisePropertyChanged("MakeModelTerm");
            if (value.Length > 2)
            {
                SearchMakeModel(value);
            }
        }
    }

    private void SearchMakeModel(string value)
    {
        LookUpRepository er = new LookUpRepository();
        var list = er.SearchMakeModel(value);
        MakeModelCollection.Clear();
        list.ForEach(MakeModelCollection.Add); // This triggers the System.ArgumentException on each value in list
        this.IsMakeModelDropDownOpen = true;
    }

  2. Answer
    Vladimir Stoyanov
    Admin
    Vladimir Stoyanov avatar
    503 posts

    Posted 21 Feb Link to this post

    Hello Bryan,

    Thank you for the provided sample code. 

    I tried to reproduce the described exception on my end, however I was not able to do so. I created a sample application based on the provided code and replaced/guessed the parts of the code that were not available and I am attaching it for your reference.

    May I ask you to check out the sample project and see how it differs from the setup on your end? Should you need any further assistance, may I kindly ask you to modify the sample project in order to reproduce the observed on your end behavior and send it back? This way I will be able to investigate the scenario on my end and better assist you. 

    I am looking forward to your reply.

    Regards,
    Vladimir Stoyanov
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
  3. Bryan
    Bryan avatar
    2 posts
    Member since:
    Feb 2014

    Posted 21 Feb in reply to Vladimir Stoyanov Link to this post

    Thanks!

     

    I realized that my TextSearchPath had a typo in it which was causing the exception.

Back to Top