コード例 #1
0
        private void Deselect(object oldSelectedElement)
        {
            var container = GetContainerFromItem(this, oldSelectedElement);

            if (container != null)
            {
                container.IsSelected = false;
                if (Equals(container, _lastSelectedItem))
                {
                    _lastSelectedItem = null;
                }
                SelectedTreeViewItems.Remove(container);
            }
        }
コード例 #2
0
 private void HandleControlKeySelection(TreeViewItem newSelected)
 {
     if (SelectedTreeViewItems.Contains(newSelected))
     {
         newSelected.IsSelected = false;
         SelectedTreeViewItems.Remove(newSelected);
         if (_lastSelectedItem != null)
         {
             _lastSelectedItem.IsSelected = true;
         }
         _lastSelectedItem = null;
     }
     else
     {
         if (_lastSelectedItem != null)
         {
             _lastSelectedItem.IsSelected = true;
         }
         SelectedTreeViewItems.Add(newSelected);
         _lastSelectedItem = newSelected;
     }
 }