Click here to Skip to main content
13,043,865 members (47,819 online)
Rate this:
Please Sign up or sign in to vote.
See more:
in WPF i saw some events like StrokeCollected , StrokeErased ,StrokeErasing ,
i want them in my Windows form for my controls like panel or pcitureBox,

is that possible to create a handler to invoke that event ?

thank you in advance
Posted 15-Nov-11 18:21pm
Mehdi Gholam 16-Nov-11 1:02am
I believe they are WPF specific, and not available on winforms.
SAKryukov 16-Nov-11 2:17am
Of course. I provided an answer on events and mentioned this.
Unfortunately, OP is in a very deep confusion about the basics, so it's hard to give him effective help. Only going back to basics can help effectively, but OP needs to be convinced. Delusions, delusions...
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

An event handler is not used to invoke the event, it is used to handle the event when it is already invoked. So, no, this is not possible.

However, you never need to invoke any event declared in any already created class — this is already done in this class (it it is implemented correctly, of course). Moreover, you never can do it, unless this is your class with the source code which you can modify. You cannot access firing event even if you try to do it in a derived class. This is one of the most important limitation of event instances compared to delegate instances.

All you can do with event declared in some already existing class is to add an event handler to its invocation list or remove previously added handler. Of course you can do it with the events you mentioned in the question. This is all you really need.


By the way, the class PictureBox is highly misused, it can be used effectively only in very simple situations and there is absolutely no need to use it in WPF. In most situations, it should not be used even in Forms. Explain your ultimate goal if you need to get some help on WPF graphics.

You should better through out the idea of mixing WPF and Forms in one UI. This is in principle possible, but not beneficial, very limited and problematic. It's mostly used for re-using legacy Forms code.

mohanrajkiller 16-Nov-11 2:28am
i will brief in detail i am trying to implement this project in winforms is that possible???
SAKryukov 16-Nov-11 3:54am
It's surely possible. It's even hard to say, what's better, it depends on some detail. Basically, if you want to get vector graphics, WPF is better as all the bases for it are already well implemented. For pixel graphics, it's a question.
SAKryukov 16-Nov-11 3:56am
I think I pretty much answered to everything in the scope of your original question. If you need details on implementation of graphical application in WPF or Forms, it should be a separate one.

So, will you consider accepting this answer formally (green button) -- thanks.
Mehdi Gholam 16-Nov-11 3:48am
SAKryukov 16-Nov-11 3:52am
Thank you, Mehdi.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

1. You do not invoke events through handlers. Events are invoked based on user actions in UI (in this case) and handler handles it.

2. You can have those events too but for that, you will have to create your own picture box. Why do you need those events anyways? If you could share that, someone can provide you with a solution.

Edit: You will have to handle the Paint event and use the Graphics object to draw the things on screen. Make use of Mouse events to get the coordinates and use Paint event to draw.
mohanrajkiller 16-Nov-11 2:31am
i am just trying to implement this project in winforms so i need those events :(
d@nish 16-Nov-11 2:34am
Updated the reply.
mohanrajkiller 16-Nov-11 2:41am
Yes i have did that using a panel i am able to draw but i have to pass it on to client screen
Mehdi Gholam 16-Nov-11 3:49am

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 16 Nov 2011
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100