Hi.
That's what I do:
1. Enable row numeration in grid settings
2. Group rows by dragging some column to group panel
3. Open any group
3. Click row number on the any row
And that's what I get:
An unhandled exception ('Unhandled Error in Silverlight Application')
Code: 4004
Category: ManagedRuntimeError
Message: Infragistics.Silverlight.InvalideActiveCellException: The ActiveCell cannot belong to a column that has it's visibility set to Collapsed
And VS opens a dialog which asks me if I want to debug this app or not. So probably problem is not in my code.
Hi,
So i tested this out, its definitely a bug. Which has been fixed and will be in the next SR. When you click on the RowSelector, it tries to set the cell in the first column of a row as Active. If that column is hidden however, you get the exception.
As a workaround, you can move your hidden columns to the end of the columns collection, and the exception will go away.
-SteveZ
Thank you.
And stupid question - how do I move hidden columns? This might be obvious for you but not so simple for me :)
Not a stupid question, i should have mentioned how :)
To move columns, you need to use the Columns collection, and the Add, Remove methods.
For example:
ColumnBase col = grid.Columns[0];
grid.Columns.Remove(col);
grid.Columns.Add(col);
col.Visibility = Visibility.Collapsed.
This won't work. Here is my code:
void xGrid_GroupByCollectionChanged(object sender, GroupByCollectionChangedEventArgs e)
{
foreach (var col in xGrid.GroupBySettings.GroupByColumns)
xGrid.Columns.Remove(col);
xGrid.Columns.Add(col);
col.Visibility = Visibility.Collapsed;
}
And I still get the same exception. Is there something I'm doing wrong?
So, the scenario which you're attempting is a bit tricky b/c of that bug.
However, the following code should pretty much do the trick. It might need some tweeks, but hopefully it should handle most situations.
When the next SR comes out, this will no longer be necessary...instead you can just toggle the visibility.
When the grid loads, store off all of the column indexes:
// Store off original indexes
int i = 0;
foreach (Column col in this.DataGrid1.Columns.DataColumns)
col.Tag = i;
i++;
bool _ignoreEvent;
void DataGrid1_GroupByCollectionChanged(object sender, GroupByCollectionChangedEventArgs e)
if (!this._ignoreEvent)
// Removing a column, actually ungroups it, so while since we are doing this,
// we need to ignore each time the event fires during this operation.
List<Column> cols = new List<Column>(e.NewGroupedColumns);
foreach (Column col in cols)
_ignoreEvent = true;
this.DataGrid1.Columns.Remove(col);
this.DataGrid1.Columns.Add(col);
col.IsGroupBy = true;
_ignoreEvent = false;
// The previous grouped columns contains what the list was previously.
// So find any columns that are no longer grouped, and restore their index, and visibility.
cols = new List<Column>(e.PreviousGroupedColumns);
if(!col.IsGroupBy)
int index = (int)col.Tag;
this.DataGrid1.Columns.Insert(index, col);
col.Visibility = Visibility.Visible;
Hope this helps