Esempio n. 1
0
        private Thumb m_rowResizerThumb; // = null

        #endregion Column Resizer Code

        #region Button Behavior Code

        protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
        {
            m_IsFromMouseButtonDown = true;

            if (this.CaptureMouse())
            {
                this.SetIsPressed(true);
                e.Handled = true;

                FrameworkElement rowItemContainer = this.DataContext as FrameworkElement;

                if (rowItemContainer != null)
                {
                    DataGridContext dataGridContext = DataGridControl.GetDataGridContext(rowItemContainer);

                    if (dataGridContext != null)
                    {
                        DataGridControl dataGridControl = dataGridContext.DataGridControl;

                        // Ensure to push the RowSelector source to the SelectionChangeManager to be able to
                        // detect that a RowSelector was used to perform a selection of Row(s) and/or Cell(s)
                        using (dataGridControl.SelectionChangerManager.PushUpdateSelectionSource(SelectionManager.UpdateSelectionSource.RowSelector))
                        {
                            if (dataGridControl.SetFocusHelper(rowItemContainer, dataGridContext.CurrentColumn, true, true, true))
                            {
                                // Keep a reference to the mouse position so we can calculate when a drag operation is actually started.
                                dataGridControl.InitializeDragPostion(e);
                            }

                            if (dataGridControl.NavigationBehavior == NavigationBehavior.RowOrCell)
                            {
                                try
                                {
                                    dataGridContext.SetCurrentColumnCore(null, false, false);
                                }
                                catch (DataGridException)
                                {
                                    // We swallow the exception if it occurs because of a validation error or Cell was read-only or any other GridException.
                                }
                            }
                        }
                    }
                }
            }

            base.OnMouseLeftButtonDown(e);

            m_IsFromMouseButtonDown = false;
        }