locked
Remove search TextBox in Toolbox in rehosted designer RRS feed

  • Question

  • Hello,

    Is there a way to remove/hide the search text box (which has the hint text of 'Search') at the top of the Toolbox in a rehosted designer?

    Thanks,

    Notre

    Wednesday, June 30, 2010 10:42 PM

Answers

  • Hi Notre,

    If you hide the search box, it also disables the search functionality. If that's what you want, you could try following code after designer is loaded.

    // hide the search box
    TextBox searchBox = toolBoxControl.Template.FindName("PART_SearchBox", toolBoxControl) as TextBox;
    searchBox.Visibility = System.Windows.Visibility.Collapsed;

    // hide the hint text, which is a TextBlock
    Grid grid = VisualTreeHelper.GetParent(searchBox) as Grid;
    foreach (UIElement item in grid.Children)
    {
        if (item is TextBlock)
        {
            item.Visibility = System.Windows.Visibility.Collapsed;
            break;
        }
    }

    Thanks,

    Tony

    • Edited by Tony Tang Thursday, July 1, 2010 3:39 AM format the content again
    • Proposed as answer by Kenny Tian - MSFT Thursday, July 1, 2010 4:19 AM
    • Marked as answer by Anders Liu - MSFT Thursday, July 1, 2010 4:46 AM
    Thursday, July 1, 2010 3:32 AM

All replies

  • I believe there is no easy way to remove/hide the search text box. If you really want to do so, you can explore the option of writing your own control template with no search box and set it to ToolboxControl.Template.
    Thursday, July 1, 2010 2:39 AM
  • Hi Notre,

    If you hide the search box, it also disables the search functionality. If that's what you want, you could try following code after designer is loaded.

    // hide the search box
    TextBox searchBox = toolBoxControl.Template.FindName("PART_SearchBox", toolBoxControl) as TextBox;
    searchBox.Visibility = System.Windows.Visibility.Collapsed;

    // hide the hint text, which is a TextBlock
    Grid grid = VisualTreeHelper.GetParent(searchBox) as Grid;
    foreach (UIElement item in grid.Children)
    {
        if (item is TextBlock)
        {
            item.Visibility = System.Windows.Visibility.Collapsed;
            break;
        }
    }

    Thanks,

    Tony

    • Edited by Tony Tang Thursday, July 1, 2010 3:39 AM format the content again
    • Proposed as answer by Kenny Tian - MSFT Thursday, July 1, 2010 4:19 AM
    • Marked as answer by Anders Liu - MSFT Thursday, July 1, 2010 4:46 AM
    Thursday, July 1, 2010 3:32 AM
  • Hi Tony,

    Disabling the search functionality is my intent, so your solution works well.

    Thanks,

    Notre

    Friday, July 2, 2010 7:12 PM
  • Hi Tony,

           When I you run your code to hide the searchbox, a "null" will be returned at the first line of your code.

           Would you give me some advice to debug?

            Thanks.

           Jothn

    Thursday, January 24, 2013 6:48 AM