BreadCrumb Search

4 posts, 1 answers
  1. James
    James avatar
    22 posts
    Member since:
    Mar 2013

    Posted 09 May 2013 Link to this post

    Hi,

    I was wondering if it would be possible to add a more detailed search feature to the BreadCrumb bar. I know it currently has a kind of search where typing the name of the item will display matching results for that level (attached currentresults.png). But to get to "Item 1.1.1" I would need to type in "Item 1\Item 1.1\Item 1.1.1". Ideally I'd just like to type in "Item 1.1.1".

    I can write the search functionality bit I just need to know what events to listen for (i.e. everytime the user types a letter) and how to display the results.

    Any ideas?

    Thanks for your help.

  2. Pavel R. Pavlov
    Admin
    Pavel R. Pavlov avatar
    1182 posts

    Posted 14 May 2013 Link to this post

    Hi James,

    This behavior is not currently supported out-of-the-box. The control shows the items available in the corresponding level. However, you can implement you custom search logic in the handler of the PreviewKeyDown event of the RadBreadcrumb control. As a start you can use this code:

    private void Breadcrumb_PreviewKeyDown(object sender, System.Windows.Input.KeyEventArgs e)
    {
        var tb = e.OriginalSource as TextBox;
        if (e.Key == System.Windows.Input.Key.Enter)
        {
            if (tb != null)
            {
                /*Custom search logic*/
     
                /*set the Path to the result of your search*/
                this.Breadcrumb.Path = @"Mother company\Item 1\Item 1.1";
            }
        }
    }

    Kind regards,
    Pavel R. Pavlov
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. UI for WPF is Visual Studio 2017 Ready
  4. James
    James avatar
    22 posts
    Member since:
    Mar 2013

    Posted 14 May 2013 Link to this post

    Pavel,

    Thanks for your response. Your suggestion does get me closer to my goal! However it doesn't allow me to present a list of search results to the user like the default way does. Is it possible to bind my custom search results to this dropdown list? Or could I override this part of the breadcrumb control with the RadAutoCompleteBox control?
  5. Answer
    Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 17 May 2013 Link to this post

    Hi James,

    Yes, you can use the RadAutoCompleteBox in the RadBreadcrumb ControlTemplate. You can replace the TextBox that is representing the historySplitButton Content with a RadAutoCompleteBox. Then you can TemplateBind the ItemsSource of the AutoCompleteBox to the RadBreadCrumb AutocompleteItems.

    Please note that the RadBreadcrumb AutocompleteItems collection has to be manually populated after the RadBreadcrumb control is loaded. Then you'll also have to make sure to change the IsInTextMode state of the Breadcrumb once a selection is made in the AutoCompleteBox. You can implement this logic in the SelectionChanged event handler of the autocomplete control.

    Finally, you'll have to manually focus the RadAutoCompleteBox as soon as the user clicks in the RadBreadcrumb and enters its TextMode.

    I implemented these suggestions in a sample solution so that you can examine and test them locally. Let us know if they help.

    Kind regards,
    Tina Stancheva
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top