why is not IsActiveChanged fired in RegionActiveAwareBehavior?

Topics: Prism v2 - Silverlight 2, Prism v2 - Silverlight 3, Prism v2 - WPF 3.5
Aug 24, 2009 at 12:57 PM

Hi all,

I was wondering, why is not IsActiveChanged fired in RegionActiveAwareBehavior for a view that is implementing IActiveAware interface, but it's only set the property IsActive.

Thx,

Riccardo

Aug 25, 2009 at 8:07 PM

Hi Riccardo, 

The RegionActiveAwareBehavior sets the IsActive property for views that implement the IActiveAware interface. The firing of .net events is responsibility of the object that owns the event (in this case the views).
To fire the IsActiveChagen event when, the usual implementation IActiveAware interface is:

	public bool IsActive
	{
            get
            {
                return this._isActive;
            }
            set
            {
                if (this._isActive != value)
                {
                    this._isActive = value;     
                     
                    // Fire IsActiveChanged event
                    RaiseIsActiveChanged();//Your logic to fire the event
                 }
            }
	}   

private void RaiseIsActiveChanged()
{
    var handler = this.IsActiveChanged;
    if (handler != null)
    {
        handler(this, EventArgs.Empty);
    } 
}

 Hope it helps! 

Matias Bonaventura
http://blogs.southworks.net/matiasb