コード例 #1
0
        private static void OnIsSelectedChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            TreeViewItem item       = (TreeViewItem)d;
            bool         isSelected = (bool)e.NewValue;

            item.Select(isSelected);

            TreeViewItemAutomationPeer peer = UIElementAutomationPeer.FromElement(item) as TreeViewItemAutomationPeer;

            if (peer != null)
            {
                peer.RaiseAutomationIsSelectedChanged(isSelected);
            }

            if (isSelected)
            {
                item.OnSelected(new RoutedEventArgs(SelectedEvent, item));
            }
            else
            {
                item.OnUnselected(new RoutedEventArgs(UnselectedEvent, item));
            }

            item.UpdateVisualState();
        }
コード例 #2
0
        // Token: 0x060058FA RID: 22778 RVA: 0x00189D6C File Offset: 0x00187F6C
        private static void OnIsSelectedChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            TreeViewItem treeViewItem = (TreeViewItem)d;
            bool         flag         = (bool)e.NewValue;

            treeViewItem.Select(flag);
            TreeViewItemAutomationPeer treeViewItemAutomationPeer = UIElementAutomationPeer.FromElement(treeViewItem) as TreeViewItemAutomationPeer;

            if (treeViewItemAutomationPeer != null)
            {
                treeViewItemAutomationPeer.RaiseAutomationIsSelectedChanged(flag);
            }
            if (flag)
            {
                treeViewItem.OnSelected(new RoutedEventArgs(TreeViewItem.SelectedEvent, treeViewItem));
            }
            else
            {
                treeViewItem.OnUnselected(new RoutedEventArgs(TreeViewItem.UnselectedEvent, treeViewItem));
            }
            treeViewItem.UpdateVisualState();
        }