コード例 #1
0
ファイル: SampleBrowser.cs プロジェクト: royosherove/cthru
 /// <summary>
 /// Selects a tree view item based on an item.
 /// </summary>
 /// <param name="firstLevelItem">Item that correlates to a the TreeViewItem.</param>
 private void SelectTreeViewItemFor(SampleTreeItem firstLevelItem)
 {
     SampleSelection.Loaded += (s, args) =>
         {
             ((TreeViewItem)SampleSelection.ItemContainerGenerator.ContainerFromItem(firstLevelItem)).IsSelected = true;
         };
 }
コード例 #2
0
ファイル: SampleBrowser.cs プロジェクト: royosherove/cthru
        /// <summary>
        /// Selects a tree view item based on an item.
        /// </summary>
        /// <param name="firstLevelItem">Item that correlates to a the first level TreeViewItem.</param>
        /// <param name="secondLevelItem">Item that correlates to a the second level TreeViewItem.</param>
        private void SelectTreeViewItemFor(SampleTreeItem firstLevelItem, SampleTreeItem secondLevelItem)
        {
            SampleSelection.Loaded += (s, args) =>
            {
                TreeViewItem firstLevelTreeViewItem = (TreeViewItem)
                    SampleSelection.ItemContainerGenerator.ContainerFromItem(firstLevelItem);
                TreeViewItem secondLevelTreeViewItem = (TreeViewItem)
                    firstLevelTreeViewItem.ItemContainerGenerator.ContainerFromItem(secondLevelItem);
                secondLevelTreeViewItem.IsSelected = true;

                // check if 3rd level deep link path has a correlating TabItem
                if (!string.IsNullOrEmpty(GetPathForLevel(2)))
                {
                    TabItem tabItemToSelect = SamplesTab.Items.OfType<TabItem>().SingleOrDefault(
                        t => ((SampleBrowserItem) t.Header).Name == GetPathForLevel(2));

                    if (tabItemToSelect != null)
                    {
                        tabItemToSelect.IsSelected = true;
                    }
                }
            };
        }