1:winform
For example, a Button whose onclick method encapsulates a statement that triggers the Click event (or raises the Click event) (such as: if (this). Click!=null) {this. Click.invoke (s,e);} The Click event that triggered the button); This is handled by Microsoft: when needed, the OnClick method is invoked to trigger the button's Click event.
2:wpf
For example, a Button whose onclick method encapsulates a statement that triggers the Button.clickevent event (or raises the Button.clickevent event) (such as: Routeeventargs newevent = new Routeeventargs (Button.clickevent,this); This. RaiseEvent (newevent);} triggering button.clickevent events); The analysis is handled by Microsoft: when needed, the OnClick method is invoked, triggering the Button.clickevent event (this is a routed event);
For CLR events, it belongs to the instance itself, such as placing a button (button1) in the form layout, and click= "Button1_Click" in the foreground XAML, which is actually the add{this that called the CLR event wrapper. AddHandler (Clickevent,value); Button1 Install the Button.clickevent event listener} accessor; If you install the Button.clickevent event listener in the Background Code Implementation button button, you need to call this.but in the form where the Button1 button is located Ton1. AddHandler (button.clickevent,new Routedeventhandler (this.button1_click))//button1 install Button.clickevent event listeners. So it concludes that the Button.clickevent event treats the button buttons as equal to the other UIElement controls in the case of installing the Button.clickevent event listener.
3: Is that not all ordinary events need to be routed events? Answer: No, the routed event can only be used in UIElement (because the RaiseEvent method comes from UIElement), the ordinary class can only define "ordinary event", this is not sure????.
4: Is that not all the normal attributes need to be changed to dependency properties? Answer: No, a dependency property can only be defined in Visual and its subclasses (because the host of the dependency property must be Dependencyobject--uielement:visual:dependencyobject), the normal data entity class can only define "Normal Properties".
Analysis of routed events and traditional events