Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
Mono organizations on
GitHub to continue tracking issues. Bugzilla will remain
available for reference in read-only mode. We will continue to work
on open Bugzilla bugs, copy them to the new locations
as needed for follow-up, and add the new items under Related
Our sincere thanks to everyone who has contributed on this bug
tracker over the years. Thanks also for your understanding as we
make these adjustments and improvements for the future.
Please create a new report for Bug 7136 on
GitHub or Developer Community if you have new
information to add and do not yet see a matching new report.
If the latest results still closely match this report, you can use the
In special cases on GitHub you might also want the comments:
GitHub Markdown with public comments
This is an example code (you'll have to add the various usings).
The problem is that the .NET BufferedGraphics uses the X and Y of the Rectangle passed as a parameter and gives to the buffer those coordinates as the origin (so if you do BufferedGraphicsManager.Current.Allocate(e.Graphics, new Rectangle(0, height1, width, height2) the origin of the buffer will be (0, height1) and the last pixel will be (width - 1, height1 + height2 - 1). On .NET if you launch the program you will get the top half of the window red and the bottom half green, on Mono you'll get the top half red and the bottom half of the color of the window.
static class Program
/// The main entry point for the application.
static void Main()
public class Form1 : Form
this.Paint += this.Form1_Paint;
this.Resize += this.Form1_Resize;
private void Form1_Paint(object sender, PaintEventArgs e)
int width = this.ClientSize.Width;
int height1 = this.ClientSize.Height / 2;
using (var bf = BufferedGraphicsManager.Current.Allocate(e.Graphics, new Rectangle(0, 0, width, height1)))
using (var br = new SolidBrush(Color.Red))
bf.Graphics.FillRectangle(br, new Rectangle(0, 0, width, height1));
int height2 = this.ClientSize.Height - height1;
using (var bf = BufferedGraphicsManager.Current.Allocate(e.Graphics, new Rectangle(0, height1, width, height2)))
using (var br = new SolidBrush(Color.Green))
// This will partially fix the BufferedGraphics, but look at the two different TextRenderer.DrawText
bf.Graphics.FillRectangle(br, new Rectangle(0, height1, width, height2));
TextRenderer.DrawText(bf.Graphics, "One", this.Font, new Point(0, height1), Color.White);
TextRenderer.DrawText(bf.Graphics, "Two", this.Font, new Point(0, height1), Color.White, TextFormatFlags.PreserveGraphicsTranslateTransform);
private void Form1_Resize(object sender, EventArgs e)