Quantcast
Viewing all articles
Browse latest Browse all 801

Commented Issue: DataGrid WSOD Exception when scrolling horizontally - with resolution [5107]

<p>The following error occurs when the Datagrid shows a horizontal scrollbar and one scrolls all to the right end.</p>
<p>&nbsp;</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&amp; outWidth, Single&amp; outHeight)</p>
<p>&nbsp;</p>
<p>The issue is created by wron rounding in the EnsureCellClip method and can be fixed as follows:</p>
<p>&nbsp;</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&#39;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 &amp;&amp; frozenLeftEdge &gt; 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!!


Viewing all articles
Browse latest Browse all 801

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>