/// <summary> /// queryTreeViewのTreeViewItemの親をたどる /// </summary> /// <param name="item">検索元TreeViewItem</param> private string[] QueryTreeViewItemParent(TreeViewItem item) { var itemList = new List<TreeViewItem>(); var hitList = new List<string>(); itemList.Add(SearchTreeViewItem); for (int i = 0; i < itemList.Count; i++) { foreach (TreeViewItem tv in itemList[i].Items) { itemList.Add(tv); if (item.IsDescendantOf(tv)) { hitList.Add((string)tv.Header); } } } return hitList.ToArray(); }