<p>The following error occurs when the Datagrid shows a horizontal scrollbar and one scrolls all to the right end.</p>
<p> </p>
<p>ManagedRuntimeError Message: System.ArgumentException: </p>
<p>Parameter name: width</p>
<p> at System.Windows.Rect..ctor(Double x, Double y, Double width, Double height)</p>
<p> at System.Windows.Controls.Primitives.DataGridCellsPresenter.EnsureCellClip(DataGridCell cell, Double width, Double height, Double frozenLeftEdge, Double cellLeftEdge)</p>
<p> at System.Windows.Controls.Primitives.DataGridCellsPresenter.ArrangeOverride(Size finalSize)</p>
<p> at System.Windows.FrameworkElement.ArrangeOverride(IntPtr nativeTarget, Single inWidth, Single inHeight, Single& outWidth, Single& outHeight)</p>
<p> </p>
<p>The issue is created by wron rounding in the EnsureCellClip method and can be fixed as follows:</p>
<p> </p>
<p> private static void EnsureCellClip(DataGridCell cell, double width, double height, double frozenLeftEdge, double cellLeftEdge)</p>
<p> {</p>
<p> // Clip the cell only if it's scrolled under frozen columns. Unfortunately, we need to clip in this case</p>
<p> // because cells could be transparent</p>
<p> if (!cell.OwningColumn.IsFrozen && frozenLeftEdge > cellLeftEdge)</p>
<p> {</p>
<p> RectangleGeometry rg = new RectangleGeometry();</p>
<p> double xClip = Math.Round(Math.Min(width, frozenLeftEdge - cellLeftEdge));</p>
<p>/* FIX HERE, ensure minimum clip width 0 to correct bad rounding in line above */</p>
<p> //rg.Rect = new Rect(xClip, 0, width - xClip, height);</p>
<p> rg.Rect = new Rect(xClip, 0, Math.Min(0, width - xClip), height); </p>
<p> cell.Clip = rg;</p>
<p> }</p>
<p> else</p>
<p> {</p>
<p> cell.Clip = null;</p>
<p> }</p>
<p> }</p>
Comments: ** Comment from web user: Alito1985 **
<p> </p>
<p>ManagedRuntimeError Message: System.ArgumentException: </p>
<p>Parameter name: width</p>
<p> at System.Windows.Rect..ctor(Double x, Double y, Double width, Double height)</p>
<p> at System.Windows.Controls.Primitives.DataGridCellsPresenter.EnsureCellClip(DataGridCell cell, Double width, Double height, Double frozenLeftEdge, Double cellLeftEdge)</p>
<p> at System.Windows.Controls.Primitives.DataGridCellsPresenter.ArrangeOverride(Size finalSize)</p>
<p> at System.Windows.FrameworkElement.ArrangeOverride(IntPtr nativeTarget, Single inWidth, Single inHeight, Single& outWidth, Single& outHeight)</p>
<p> </p>
<p>The issue is created by wron rounding in the EnsureCellClip method and can be fixed as follows:</p>
<p> </p>
<p> private static void EnsureCellClip(DataGridCell cell, double width, double height, double frozenLeftEdge, double cellLeftEdge)</p>
<p> {</p>
<p> // Clip the cell only if it's scrolled under frozen columns. Unfortunately, we need to clip in this case</p>
<p> // because cells could be transparent</p>
<p> if (!cell.OwningColumn.IsFrozen && frozenLeftEdge > cellLeftEdge)</p>
<p> {</p>
<p> RectangleGeometry rg = new RectangleGeometry();</p>
<p> double xClip = Math.Round(Math.Min(width, frozenLeftEdge - cellLeftEdge));</p>
<p>/* FIX HERE, ensure minimum clip width 0 to correct bad rounding in line above */</p>
<p> //rg.Rect = new Rect(xClip, 0, width - xClip, height);</p>
<p> rg.Rect = new Rect(xClip, 0, Math.Min(0, width - xClip), height); </p>
<p> cell.Clip = rg;</p>
<p> }</p>
<p> else</p>
<p> {</p>
<p> cell.Clip = null;</p>
<p> }</p>
<p> }</p>
Comments: ** Comment from web user: Alito1985 **
I am having the following error and my silverlight App closes immediately, I don't know where is the issue or how I can reproduce it. Here is the message I received
ManagedRuntimeError Message: System.ArgumentException:
Parameter name: width
System.Windows.Rect..ctor(Double x, Double y, Double width, Double height)
Any Idea? I read the previous post but I don't really understand how to fix it.
Thanks in advance!!