示例#1
0
 static void ClearSelectionIfRowIsNotBeSelectable(DataGrid grid, RowViewModel firstSelectedRowFound)
 {
     if (firstSelectedRowFound != null && !firstSelectedRowFound.IsSelectable)
     {
         grid.SelectedCells.Clear();
     }
 }
示例#2
0
        /// <summary>
        /// Prevents User from selecting items from different Rows, as it doesn't make sense to analyse them together
        /// </summary>
        /// <param name="grid"></param>
        static void LimitSelectionToOneRow(DataGrid grid)
        {
            RowViewModel firstSelectedRowFound = null;

            foreach (DataGridCellInfo gridCellInfo in grid.SelectedCells)
            {
                if (firstSelectedRowFound == null)
                {
                    firstSelectedRowFound = (RowViewModel)gridCellInfo.Item;
                }
                else if (IsOnAnotherRow(gridCellInfo, firstSelectedRowFound))
                {
                    grid.SelectedCells.Remove(gridCellInfo);
                }
            }

            ClearSelectionIfRowIsNotBeSelectable(grid, firstSelectedRowFound);
        }
示例#3
0
 static bool IsOnAnotherRow(DataGridCellInfo gridCellInfo, RowViewModel firstFoundSelectedRow)
 {
     return(gridCellInfo.Item != firstFoundSelectedRow);
 }