Painting on PDFViewWPF

I try to paint in my WPF PDF viewer.

If no PDF is loaded, this works.

When i opened a file, the painted things are not longer visible.

I would like that my red rectangle drawn (and displayed), even if a file is opened.

That’s my OnRender Method, what i’m doing wrong?

`

`

public class PDFView : PDFViewWPF

{

// …

#region Drawing

protected override void OnRender(DrawingContext drawingContext)

{

Trace.WriteLine(“PDFView: OnRender”);

base.OnRender(drawingContext);

drawingContext.DrawRectangle(Brushes.Red, new Pen(Brushes.Black, 0), new System.Windows.Rect(150, 150, 100, 100));

}

#endregion Drawing

// …

}

`

`






The answer is given by Chales Petzold here.



His answer is ‘don’t know why’, however a comment correctly suggests that setting the window’s Background to transparent fixes the bug.



It is possible that Grid generates this problem. Default Window contains a Grid element.


On Wednesday, May 23, 2012 12:57:39 AM UTC-7, David wrote:

I try to paint in my WPF PDF viewer.

If no PDF is loaded, this works.

When i opened a file, the painted things are not longer visible.

I would like that my red rectangle drawn (and displayed), even if a file is opened.

That’s my OnRender Method, what i’m doing wrong?

`

`

public class PDFView : PDFViewWPF

{

// …

#region Drawing

protected override void OnRender(DrawingContext drawingContext)

{

Trace.WriteLine(“PDFView: OnRender”);

base.OnRender(drawingContext);

drawingContext.DrawRectangle(Brushes.Red, new Pen(Brushes.Black, 0), new System.Windows.Rect(150, 150, 100, 100));

}

#endregion Drawing

// …

}

`

`

Also,
see http://social.msdn.microsoft.com/forums/en-US/wpf/thread/750e91c2-c370-4f0a-b18e-892afd99bd9b