The error message appears here
---------------------------
---------------------------
Row Loaded
Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
Stack Trace
at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
at System.ThrowHelper.ThrowArgumentOutOfRangeException()
at System.Collections.Generic.List`1.get_Item(Int32 index)
at RRI.PMDG.UI.Controls.MainPage.GridViewRowLoaded(RowLoadedEventArgs e, Object sender)
---------------------------
OK
---------------------------
private void GridViewRowLoaded(RowLoadedEventArgs e, object sender)
{
try
{
if (e.Row is GridViewRow)
{
if ((sender as RadGridView) != null) //Make sure that casting doesn't fail
{
int cellCount = e.Row.Cells.Count;
if (cellCount >= 5) // a legacy I don't understand.
{
//_riskFactor = "Factor";
var CellFgBinding = new System.Windows.Data.Binding("Factor");
CellFgBinding.Converter = new AssementColorConverter(cardInfoColActive.AssesmentColorItems);
e.Row.Cells[(sender as RadGridView).Columns[_riskFactor].DisplayIndex].SetBinding(GridViewCellBase.BackgroundProperty, CellFgBinding);
var safetyBgBinding = new System.Windows.Data.Binding("SafetyRiskRankColor");
safetyBgBinding.Converter = new SafetyColorConverter();
int displayIndex = (sender as RadGridView).Columns["SafetyRiskRankDescription"].DisplayIndex;
if (cellCount > displayIndex)
{
GridViewCellBase gridViewCell = e.Row.Cells[displayIndex];
gridViewCell.SetBinding(BackgroundProperty, safetyBgBinding);
}
}
}
}
}
catch (Exception ex)
{
#region TRASH
MessageBox.Show("Row Loaded\n" + ex.Message+
"\nStack Trace\n" + ex.StackTrace);
#endregion
}
}