How to know if a property is up to date now or not?

Can I know whether a property is out of date or not by myself ?
I want to do the following code:

private int _y;
public int Y
{
get
{
if ( IsOutOfDate == true )
_y = _x*_x + 2;
return _y;
}
set
{
_y = value;
( notify Y changed here )
}
}

private int _x;
public int X
{
get
{
if ( IsOutOfDate == true )
_x = sqrt(_y - 2);
return _x;
}
set
{
_x = value;
( notify X changed here )
}
}

so that _x and _y can be inter-dependant. Whenever _x changes, Y will recalculate its value, otherwise, it will just return its own field, and vice versa. This is especially useful when the "get method" involved heavy calculation like linq or something.

I believe with updatecontrols, there will be no need for the "Multibinding" or "bindingconverter" of wpf.

Reply

By submitting this form, you accept the Mollom privacy policy.