locked
Is it possible to marshal DrawingContext to native code RRS feed

  • Question

  • I have some custom control with some trivial OnRender method:

            protected override void OnRender(DrawingContext dc)
            {
                base.OnRender(dc);
    
                SolidColorBrush mySolidColorBrush = new SolidColorBrush();
                
                mySolidColorBrush.Color = Colors.SandyBrown;
                
                Pen myPen = new Pen(Brushes.Blue, 6);
    
                Rect myRect = new Rect(0, 0, _extent.Width, _extent.Height);
                
                dc.DrawRectangle(mySolidColorBrush, myPen, myRect);
                            
                //drawingContext.DrawText(m_formattedText, m_textPos);
            }
    
    is it right that DrawingContext has underlying Direct2D ID2D1DeviceContext and ID2D1RenderTarget? If so, is it possible to pass pointers to this interfaces from my OnRender to native code written in pure C++ without CLI and do some drawing with them?

    Dmitriano http://developernote.com

    Tuesday, June 17, 2014 9:53 AM

Answers

  • "is it right that DrawingContext has underlying Direct2D ID2D1DeviceContext and ID2D1RenderTarget?"

    Nope. WPF does not use Direct2D and the way DrawingContext works is very different from the way Direct2D's device context/render target work.

    • Marked as answer by Dmitriano1 Tuesday, June 17, 2014 11:48 AM
    Tuesday, June 17, 2014 11:47 AM