Ejemplo n.º 1
0
 public void ClearSelection()
 {
     //popupDataGrid.SelectedIndex = -1;
     popupDataGrid.UnselectAll();
     //popupDataGrid.ScrollIntoView(popupDataGrid.SelectedIndex);
     //ScrollViewer scrollViewer = GetScrollViewer(popupDataGrid) as ScrollViewer;
     //scrollViewer.ScrollToHome();
 }
Ejemplo n.º 2
0
        private static void ToolkitGridColumnFastEditOnFocus(Microsoft.Windows.Controls.DataGridCell cell, KeyboardFocusChangedEventArgs e)
        {
            if (cell == null || cell.IsEditing || cell.IsReadOnly)
            {
                return;
            }

            Microsoft.Windows.Controls.DataGrid dataGrid = FindVisualParent <Microsoft.Windows.Controls.DataGrid>(cell);
            if (dataGrid == null)
            {
                return;
            }

            dataGrid.UnselectAll();

            if (dataGrid.SelectionUnit != Microsoft.Windows.Controls.DataGridSelectionUnit.FullRow)
            {
                if (!cell.IsSelected)
                {
                    cell.IsSelected = true;
                }
            }
            else
            {
                Microsoft.Windows.Controls.DataGridRow row = FindVisualParent <Microsoft.Windows.Controls.DataGridRow>(cell);
                if (row != null && !row.IsSelected)
                {
                    row.IsSelected = true;
                }
            }

            String statusmsg = "";

            if (cell.Content is TextBlock)
            {
                TextBlock tb = cell.Content as TextBlock;
                if (tb != null)
                {
                    statusmsg = tb.Text;
                }
            }
            else if (cell.Content is TextBox)
            {
                TextBox tb = cell.Content as TextBox;
                if (tb != null)
                {
                    statusmsg = tb.Text;
                }
            }
            else if (cell.Content is ComboBox)
            {
                ComboBox cb = cell.Content as ComboBox;
                if (cb != null)
                {
                    statusmsg = cb.Text;
                    //DataGrid dataGrid = FindVisualParent<DataGrid>(cell);
                    cell.Dispatcher.Invoke(
                        DispatcherPriority.Background,
                        new Action(delegate { }));
                    cb.IsDropDownOpen = true;
                }
            }
            if (cell.Content is ContentPresenter)
            {
                TextBlock tb = FindVisualChild <TextBlock>(cell);
                if (tb != null)
                {
                    statusmsg = tb.Text;
                }
            }

            StatusMessage.setStatus(statusmsg);
        }