コード例 #1
0
        /// <summary>
        /// Handles preview mouse down event
        /// </summary>
        /// <param name="e">The event args</param>
        protected override void OnPreviewMouseDown(MouseButtonEventArgs e)
        {
            if (!this.IsSelected)
            {
                // unselect all other items of same level and selected this item
                ControlHelper.FindParentCanvas(this).ClearSelection();
                this.IsSelected = true;
            }

            this.Focus();
            e.Handled = false;
        }
コード例 #2
0
        /// <summary>
        /// Handles preview mouse down event
        /// </summary>
        /// <param name="e">The event args</param>
        protected override void OnPreviewMouseDown(MouseButtonEventArgs e)
        {
            if (!this.IsSelected)
            {
                // unselect all other items of same level and selected this item
                var parentCanvas = ControlHelper.FindParentCanvas(this);
                parentCanvas.ClearSelection();

                OmrChoiceBox grandParentCanvas = ControlHelper.FindParentChoiceBox(parentCanvas);
                if (grandParentCanvas.IsSelected)
                {
                    this.IsSelected = true;
                }
            }

            //this.Focus();
            e.Handled = false;
        }
コード例 #3
0
        /// <summary>
        /// Handles preview mouse down event
        /// </summary>
        /// <param name="e">The event args</param>
        protected override void OnPreviewMouseDown(MouseButtonEventArgs e)
        {
            base.OnPreviewMouseDown(e);

            // update selection
            if ((Keyboard.Modifiers & (ModifierKeys.Shift | ModifierKeys.Control)) != ModifierKeys.None)
            {
                // if key modifiers used -> reverse selection (select if was unselected and vice versa)
                this.IsSelected = !this.IsSelected;
            }
            else if (!this.IsSelected)
            {
                // no modifiers used and item wasn't selected -> clear selection on canvas and select item
                ControlHelper.FindParentCanvas(this).ClearSelection();
                this.IsSelected = true;
            }

            this.Focus();
            e.Handled = false;
        }