I am trying to migrate my application from WinForms to WPF. I have an application developed in C# with GDI+ (similar to MS paint). I want to write the same application in WPF but I don’t know how to perform graphics operation like GDI+?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
What do you want to do exactly?
One way to do custom drawings in WPF is to create a class that inherits from UIElement and then to override the OnRender method. In this method you will have access to a DrawingContext which will allow you to call basic drawing methods which are in many ways similar to the methods in GDI+.
Otherwise you probably want to create Visuals or higher level objects and put them on a Canvas. This will be slower but then you can take better advantage of WPF features such as animations and data binding.
EDIT:
Here is a codeproject article series describing how to create a Diagram Designer in WPF:
http://www.codeproject.com/KB/WPF/WPFDiagramDesigner_Part1.aspx
http://www.codeproject.com/KB/WPF/WPFDiagramDesigner_Part2.aspx
http://www.codeproject.com/KB/WPF/WPFDiagramDesigner_Part3.aspx
http://www.codeproject.com/KB/WPF/WPFDiagramDesigner_Part4.aspx