header click and cell click not working after subclassing datagrid

Apr 21, 2009 at 3:58 AM
Hi, I subclassed the datagrid but the header click (sort) nor a specific cell click work anymore, any clues why?  I tried to make a new default template for my custom control, but didn't work... ?



Apr 21, 2009 at 5:40 AM
hi, nevermind, i was overriding the OnPreviewMouseLeftButtonDown and set it handled to be true.  I am implementing custom scrolling so I want to handle the mouse down, move, and up command, but not for the headers nor the last column. Would this be the most efficient way to do this?

        protected override void OnPreviewMouseLeftButtonDown(System.Windows.Input.MouseButtonEventArgs e)
            var element = this.InputHitTest(e.GetPosition(this)) as DependencyObject;
            var cell = WpfHelper.TryFindParent<DataGridCell>(element);
            if (cell != null)
                // see if last column - let click through
                if (this.Columns.Count > 0 && cell.Column != this.Columns[this.Columns.Count - 1])
                    _mouseDown = true;
                   // Start custom scroll behavior

                    // handle the event to prevent the item in the listbox to be selected
                    e.Handled = true;
            _mouseDown = false;