AutoComplete is not working

4 posts, 0 answers
  1. Ramesh
    Ramesh avatar
    19 posts
    Member since:
    Mar 2013

    Posted 15 Mar 2013 Link to this post

    Hi Experts,

    I have tried your AutoCompleteBox with the following code, but it is not working. I could not get any suggesstions and the dropdown list is not showing any suggesstion list. Simply the control works like a TextBox only. Please help me, what is my wrong.

    <Window x:Class="Interactivity_Behavior_Demo.MainWindow"
            xmlns:local="clr-namespace:Interactivity_Behavior_Demo.Behavior"
            Title="Test Demo"
            Width="525"
            Height="350">
      
          
            <Telerik:RadAutoCompleteBox Name="autocomp" Loaded="autocomp_Loaded_1" Height="30" Width="120"/>
             
    </Window
      
    public MainWindow()
            {
                InitializeComponent();
                _Source = new ObservableCollection<string>() { "hello", "abc", "123" };
                autocomp.ItemsSource = Source;
            }
        
    private void autocomp_Loaded_1(object sender, RoutedEventArgs e) 
            
                autocomp.IsDropDownOpen = true; 
                autocomp.AutoCompleteMode = Telerik.Windows.Controls.Primitives.AutoCompleteMode.Suggest; 
                autocomp.TextSearchMode = Telerik.Windows.Controls.TextSearchMode.StartsWith; 
            }
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 18 Mar 2013 Link to this post

    Hi Ramesh,

    I tried your code with a few modifications and its working fine at my end. You have given a wrong variable name while setting the ItemsSource and you have initialized the ObservableCollection without specifying the type. Please have a look into the following code.

    XAML:
    <telerik:RadAutoCompleteBox HorizontalAlignment="Left" Margin="34,64,0,0" Name="autocomp" VerticalAlignment="Top" Width="224" Loaded="radAutoCompleteBox1_Loaded" />

    C#:
    public MainWindow()
    {
        InitializeComponent();
        ObservableCollection<string> _Source = new ObservableCollection<string>() { "hello", "abc", "123" };
        autocomp.ItemsSource = _Source;
    }
     
    private void radAutoCompleteBox1_Loaded(object sender, RoutedEventArgs e)
    {
        autocomp.IsDropDownOpen = true;
        autocomp.AutoCompleteMode = Telerik.Windows.Controls.Primitives.AutoCompleteMode.Suggest;
        autocomp.TextSearchMode = Telerik.Windows.Controls.TextSearchMode.StartsWith;
    }

    Thanks,
    Princy.
  3. UI for WPF is Visual Studio 2017 Ready
  4. Ramesh
    Ramesh avatar
    19 posts
    Member since:
    Mar 2013

    Posted 18 Mar 2013 Link to this post

    Princy,
    Thanks for your response.

    This is working fine when i have the control seperately.

    But i am using this inside RadGrid cell, when i have this inside the with CellEditTemplate and clicking the cell throws null exception.
    Also i dont know what i have to add in "CellTemplate", please help me by providing code for both "CellTemplate" and "CellEditTemplate" with AutoCompleteBox.

    Thanks,
    Ramesh
    velusamyr@hcl.com
  5. Vladi
    Admin
    Vladi avatar
    744 posts

    Posted 21 Mar 2013 Link to this post

    Hi Ramesh,

    We created and attached a sample project for you that shows how to create a CellEditTemplate and CellTemplate with RadAutoCompleteBox in RadGridView.

    Hope this is helpful.

    Greetings,
    Vladi
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top