Graphics.DrawString not drawing when picturebox handle is outputsource of directX11 device

39 viewsdirectx 11windowsformshostwinformswpf
0

Picturebox handle is set as the outputSource of DirectX11. directX is rendering on the picturebox handle.

I am also drawing text on the picturebox in paint event. But the text is not shown. If i don’t set the handle as directX11 output source, the text is shown on the picturebox. How I can draw text on the picturebox when directX is rendering on it.

N.B: The picturebox is inside WindowsFormsHost in wpf app.

private void pictureBox1_Paint(object sender, PaintEventArgs e)
    {
        using (Font myFont = new Font("Arial", 14))
        {
            e.Graphics.DrawString("Hello .NET Guide!", myFont, System.Drawing.Brushes.Green, new System.Drawing.Point(20, 20)); // this text is not shown.
        }
    }