Events

  • Thread starter Thread starter Ferdinand Zaubzer
  • Start date Start date
F

Ferdinand Zaubzer

As far as I know events are fired by invoking a method.
Is it possible that events are fired if a boolean property changes its
value?

Thanks
Ferdinand
 
Ferdinand,

Events can be fired for any reason whatsoever. It is up to the defining
class to indicate when events should be fired.

There is nothing that says you can't fire an event if a property changes
it's value.

If you want to do this, you should look into the INotifyPropertyChanged
interface, as it defines a standard event that is used to indicate when a
property changes.

Hope this helps.
 
Very interesting. Does this mean that MS is abandoning the

public xxxx MyProperty ...

public event yyyy MyPropertyChanged;

protected void OnMyPropertyChanged() ...

pattern in favour of this new INotifyPropertyChanged interface?
Ferdinand,

Events can be fired for any reason whatsoever. It is up to the defining
class to indicate when events should be fired.

There is nothing that says you can't fire an event if a property changes
it's value.

If you want to do this, you should look into the INotifyPropertyChanged
interface, as it defines a standard event that is used to indicate when a
property changes.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Ferdinand Zaubzer said:
As far as I know events are fired by invoking a method.
Is it possible that events are fired if a boolean property changes its
value?

Thanks
Ferdinand
 
Bruce,

It's not abandoning it. However, it does prefer that you use that, as
it offers a performance gain (you don't have a gazillion delegates to hook
up to to detect property changes).

WPF is going to take advantage of this as well.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Bruce Wood said:
Very interesting. Does this mean that MS is abandoning the

public xxxx MyProperty ...

public event yyyy MyPropertyChanged;

protected void OnMyPropertyChanged() ...

pattern in favour of this new INotifyPropertyChanged interface?
Ferdinand,

Events can be fired for any reason whatsoever. It is up to the
defining
class to indicate when events should be fired.

There is nothing that says you can't fire an event if a property
changes
it's value.

If you want to do this, you should look into the
INotifyPropertyChanged
interface, as it defines a standard event that is used to indicate when a
property changes.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Ferdinand Zaubzer said:
As far as I know events are fired by invoking a method.
Is it possible that events are fired if a boolean property changes its
value?

Thanks
Ferdinand
 
Back
Top