Observable Collection to add items.

2 posts, 1 answers
  1. Henry
    Henry avatar
    44 posts
    Member since:
    Feb 2013

    Posted 18 Mar 2013 Link to this post

    Hi,

    How to set the AutoComplete items from code behind using an ObservableCollection? Can anyone give me sample code.

    Henry.
  2. Answer
    Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 18 Mar 2013 Link to this post

    Hi,

    Please have a look into the following sample code.

    XAML:
    <telerik:RadAutoCompleteBox Width="150" Name="autocomp" Height="30" Loaded="RadAutoCompleteBox_Loaded"></telerik:RadAutoCompleteBox>

    C#:
    public MainPage()
    {
        InitializeComponent();
        ObservableCollection<string> _Source = new ObservableCollection<string>() { "Item1", "Item2", "Item3" };
        autocomp.ItemsSource = _Source;
    }
     
    private void RadAutoCompleteBox_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. DevCraft banner
Back to Top