Csharp-Data-Visualization icon indicating copy to clipboard operation
Csharp-Data-Visualization copied to clipboard

The Type or namespace "RectangleF' could not be found (are you missing a using directive or assembly reference)

Open robreno opened this issue 1 year ago • 1 comments

  1. RectangleF: Error CS0246 The type or namespace name 'RectangleF' could not be found (are you missing a using directive or an assembly reference?)

  2. Quick Actions adds: "using System.Drawing" but this creates a conflict with Maui.Graphics and is the incorrect Rect type for the following line of code "canvas.FillRectangle(rect)" and other Maui.Graphics references (e.g., Color, convas, etc.).

  3. To test I added "using SDraw = System.Drawing" yielding SDraw.RectangleF rect = new( ... but as noted above RectangleF is wrong type for "canvas.FillRectangle(rect)".

  4. Added following and worked correctly:

Rect newRect = new(
                    x: columnIndex * cellWidthPx + xPad,
                    y: rowIndex * cellHeightPx + yPad,
                    width: cellWidthPx - xPad * 2,
                    height: cellHeightPx - yPad * 2);
canvas.FillRectangle(newRect);
  1. Fix is to use Maui.Graphics.Rect (rather than System.Drawing.RectangleF) .

robreno avatar May 02 '23 17:05 robreno