How do I pass objects in EventArgs

You would have to declare your event using EventHandler<T> where T is your class that derives from EventArgs: public event EventHandler<LoginCompletedEventArgs> LoginCompleted; LoginCompletedEventArgs could look like this: public class LoginCompletedEventArgs : EventArgs { private readonly YourBusinessObject _businessObject; public LoginCompletedEventArgs(YourBusinessObject businessObject) { _businessObject = businessObject; } public YourBusinessObject BusinessObject { get { return _businessObject; } } … Read more

How do I make an eventhandler run asynchronously?

So you want to raise the event in a manner that prevents the listeners from blocking the background thread? Gimme a couple minutes to whip up an example; it’s pretty simple 🙂 Here we go: first an important note! Whenever you call BeginInvoke you must call the corresponding EndInvoke, otherwise if the invoked method threw … Read more

What is the use of “object sender” and “EventArgs e” parameters?

EventArgs e is a parameter called e that contains the event data, see the EventArgs MSDN page for more information. Object Sender is a parameter called Sender that contains a reference to the control/object that raised the event. Event Arg Class: http://msdn.microsoft.com/en-us/library/system.eventargs.aspx Example: protected void btn_Click (object sender, EventArgs e){ Button btn = sender as … Read more

MVVM Passing EventArgs As Command Parameter

It’s not easily supported. Here’s an article with instructions on how to pass EventArgs as command parameters. You might want to look into using MVVMLight – it supports EventArgs in command directly; your situation would look something like this: <i:Interaction.Triggers> <i:EventTrigger EventName=”Navigated”> <cmd:EventToCommand Command=”{Binding NavigatedEvent}” PassEventArgsToCommand=”True” /> </i:EventTrigger> </i:Interaction.Triggers>

Does .NET have a built-in EventArgs?

No. You probably were thinking of EventHandler<T>, which allows you to define the delegate for any specific type of EventArgs. I personally don’t feel that EventArgs<T> is quite as good of a fit, though. The information used as a “payload” in the event args should be, in my opinion, a custom class to make its … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)