height = height + itemMargin.Top + itemMargin.Bottom;
StepCandidate = IsHorizontal? width : height;
CandidateMargin = new Extents(itemMargin);
+
+ // Prevent zero division.
+ if (width == 0) width = 1;
+ if (height == 0) height = 1;
spanSize = IsHorizontal?
Convert.ToInt32(Math.Truncate((double)((colView.Size.Height - Padding.Top - Padding.Bottom) / height))) :
Convert.ToInt32(Math.Truncate((double)((colView.Size.Width - Padding.Start - Padding.End) / width)));
else
{
float visibleAreaX = visibleArea.X - (hasHeader ? headerSize : 0);
- found.start = (Convert.ToInt32(Math.Abs(visibleAreaX / StepCandidate)) - 1) * spanSize;
+ // Prevent zero division.
+ var itemSize = (StepCandidate != 0)? StepCandidate: 1f;
+ found.start = (Convert.ToInt32(Math.Abs(visibleAreaX / itemSize)) - 1) * spanSize;
if (hasHeader) found.start += 1;
}
if (found.start < 0) found.start = 0;
{
float visibleAreaY = visibleArea.Y - (hasHeader ? headerSize : 0);
//Need to Consider GroupHeight!!!!
- found.end = (Convert.ToInt32(Math.Abs(visibleAreaY / StepCandidate)) + 1) * spanSize + adds;
+ // Prevent zero division.
+ var itemSize = (StepCandidate != 0)? StepCandidate: 1f;
+ found.end = (Convert.ToInt32(Math.Abs(visibleAreaY / itemSize)) + 1) * spanSize + adds;
if (hasHeader) found.end += 1;
}
if (found.end > (MaxIndex)) found.end = MaxIndex;
else
{
float visibleAreaX = visibleArea.X - (hasHeader? headerSize : 0);
- found.start = (Convert.ToInt32(Math.Abs(visibleAreaX / StepCandidate)) - adds);
+ // Prevent zero division.
+ var itemSize = (StepCandidate != 0)? StepCandidate : 1f;
+ found.start = (Convert.ToInt32(Math.Abs(visibleAreaX / itemSize)) - adds);
}
if (found.start < 0) found.start = 0;
else
{
float visibleAreaY = visibleArea.Y - (hasHeader? headerSize : 0);
- found.end = (Convert.ToInt32(Math.Abs(visibleAreaY / StepCandidate)) + adds);
+ // Prevent zero division.
+ var itemSize = (StepCandidate != 0)? StepCandidate : 1f;
+ found.end = (Convert.ToInt32(Math.Abs(visibleAreaY / itemSize)) + adds);
if (hasHeader) found.end += 1;
}
if (found.end > (MaxIndex)) found.end = MaxIndex;