tags:

views:

51

answers:

1

Hi, I am trying to migrate from WinFroms 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+?

+2  A: 

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

Patrick Klug
Thanks. Actually I am writing a simple paint like application. User can draw anything with pencil or brush or he/she can drag-drop some objects such as flowchart components and should be able to move it.
Vinod Maurya
Is it good to do custom graphics in WPF? Or I should use GDI+?
Vinod Maurya