Esempio n. 1
0
        //the RadTreeView.ItemsSource collection is traversed to find an item by a provided name
        private void Search(object sender, RoutedEventArgs e)
        {
            if (!string.IsNullOrEmpty(searchTextBox.Text))
            {
                searchText = searchTextBox.Text.ToLower();
                foreach (Category category in radTreeView.ItemsSource)
                {
                    if (category.Name.ToLower().Contains(searchText))
                    {
                        RadTreeViewItem item = radTreeView.GetItemByPath(category.Path);
                        item.BringIntoView();
                        item.IsSelected = true;
                        return;
                    }
                    foreach (Product product in category.Products)
                    {
                        if (product.Name.ToLower().Contains(searchText))
                        {
                            RadTreeViewItem item = radTreeView.GetItemByPath(category.Path + "\\" + product.Path);
                            item.BringIntoView();
                            item.IsSelected = true;
                            return;
                        }
                    }
                }
            }

            isFiltered = false;
        }
        static void OnTreeViewItemSelected(object sender, RoutedEventArgs e)
        {
            // Only react to the Selected event raised by the RadTreeViewItem
            // whose IsSelected property was modified. Ignore all ancestors
            // who are merely reporting that a descendant's Selected fired.
            if (!Object.ReferenceEquals(sender, e.OriginalSource))
            {
                return;
            }

            RadTreeViewItem item = e.OriginalSource as RadTreeViewItem;

            if (item != null)
            {
                item.BringIntoView();
            }
        }