G
Guest
I want to fire an event within the property of a class. Here's an example:
private bool _canprint;
public bool CanPrint
{
get
{
return _canprint;
}
set
{
_canprint = value;
try
{
if (ModelEvent != null)
{
//ModelEvent(this, new EventArgs());
//ModelEvent("CanPrint", new EventArgs());
}
}
catch
{
// Handle exceptions
}
}
}
Originally I used the "this" keyword, as I had seen elsewhere. But this
just passes the instantiation of the class and not the property itself. The
problem is that I don't know precisely which Property is firing the event.
So I thought about just changing it to a string but that seems less than
elegant.
Hoping someone can suggest how I can pass a reference to the property itself.
Robert W.
MWTech
Vancouver, BC
private bool _canprint;
public bool CanPrint
{
get
{
return _canprint;
}
set
{
_canprint = value;
try
{
if (ModelEvent != null)
{
//ModelEvent(this, new EventArgs());
//ModelEvent("CanPrint", new EventArgs());
}
}
catch
{
// Handle exceptions
}
}
}
Originally I used the "this" keyword, as I had seen elsewhere. But this
just passes the instantiation of the class and not the property itself. The
problem is that I don't know precisely which Property is firing the event.
So I thought about just changing it to a string but that seems less than
elegant.
Hoping someone can suggest how I can pass a reference to the property itself.
Robert W.
MWTech
Vancouver, BC