Exemplo n.º 1
0
        private void OnAnyMouseLeftButtonDown(System.Windows.Input.MouseButtonEventArgs e)
        {
            // Ignore actions if the button down arises from a different presentation source
            if (!PresentationSource.UnderSamePresentationSource(e.OriginalSource as DependencyObject, this))
            {
                return;
            }

            DataGridRow rowOwner      = DataGridRowOwner;
            DataGrid    dataGridOwner = rowOwner != null ? rowOwner.DataGridOwner : null;

            if ((dataGridOwner != null) && (rowOwner != null))
            {
                // HandleSelectionForRowHeaderAndDetailsInput below sets the CurrentCell
                // of datagrid to the cell with displayindex 0 in the row.
                // This implicitly queues a request to MakeVisible command
                // of ScrollViewer. The command handler calls MakeVisible method of
                // VirtualizingStackPanel (of rows presenter) which works only
                // when the visual's parent layout is clean. DataGridCellsPanel layout is
                // not clean as per MakeVisible of VSP becuase we distribute the layout of cells for the
                // sake of row headers and hence it fails. VSP.MakeVisible method requeues a request to
                // ScrollViewer.MakeVisible command hence resulting into an infinite loop.
                // The workaround is to bring the concerned cell into the view by calling
                // ScrollIntoView so that by the time MakeVisible handler of ScrollViewer is
                // executed the cell is already visible and the handler succeeds.
                if (dataGridOwner.CurrentCell.Item != rowOwner.Item)
                {
                    dataGridOwner.ScrollIntoView(rowOwner.Item, dataGridOwner.ColumnFromDisplayIndex(0));
                }

                dataGridOwner.HandleSelectionForRowHeaderAndDetailsInput(rowOwner, /* startDragging = */ Mouse.Captured == null);
            }
        }
Exemplo n.º 2
0
        // Token: 0x06005D22 RID: 23842 RVA: 0x001A35F0 File Offset: 0x001A17F0
        private void OnAnyMouseLeftButtonDown(MouseButtonEventArgs e)
        {
            if (!PresentationSource.UnderSamePresentationSource(new DependencyObject[]
            {
                e.OriginalSource as DependencyObject,
                this
            }))
            {
                return;
            }
            DataGridRow dataGridRowOwner = this.DataGridRowOwner;
            DataGrid    dataGrid         = (dataGridRowOwner != null) ? dataGridRowOwner.DataGridOwner : null;

            if (dataGrid != null && dataGridRowOwner != null)
            {
                if (dataGrid.CurrentCell.Item != dataGridRowOwner.Item)
                {
                    dataGrid.ScrollIntoView(dataGridRowOwner.Item, dataGrid.ColumnFromDisplayIndex(0));
                }
                dataGrid.HandleSelectionForRowHeaderAndDetailsInput(dataGridRowOwner, Mouse.Captured == null);
            }
        }