private void CategoryItem_Selected(object sender, RoutedEventArgs e) { TreeViewItem this_TreeViewItem = e.Source as TreeViewItem; TypeDigest categoryTypeDigest = (TypeDigest)this_TreeViewItem.Tag; DictionaryTree.Items.Clear(); foreach (TypeDigest dictionaryTypeDigest in _typeRepository.GetTypeDigestsByCategory(categoryTypeDigest.Id)) { if (dictionaryTypeDigest.ParentId == null) { DictionaryTree.Items.Add(CreateTypeDigestTreeViewItem(dictionaryTypeDigest.Code, dictionaryTypeDigest)); } } }