How to implement IActiveAware on viewmodel

Docking/MDI for WPF Forum

Posted 10 years ago by Peter Schregle
Version: 11.2.0553

I'm having trouble implementing IActiveAware on a viewmodel.

Is there any sample showing how to do this?



Comments (1)

Answer - Posted 10 years ago by Actipro Software Support - Cleveland, OH, USA

Hi Peter,

Sorry, but we don't currently have any samples like that. Typically, the IActiveAware is implemented on the View, not the View Model. There is a bit of a discussion on this here. In some internal applications, we simply forward the IsActive setting from the View to the associated View Model, assuming it implements IActiveAware. Something like:

public class ViewBase : UserControl, IActiveAware {

	private bool isActive;

	public bool IsActive {
		get {
			return this.isActive;
		set {
			if (this.isActive != value) {
				this.isActive = value;

				var viewModelActiveAware = this.DataContext as IActiveAware;
				if (viewModelActiveAware != null)
					viewModelActiveAware.IsActive = value;


	public event EventHandler IsActiveChanged;

	protected virtual void OnIsActiveChanged() {
		var handler = this.IsActiveChanged;
		if (handler != null)
			handler(this, EventArgs.Empty);

But this could be wrapped into an attached behavior as well. 

Actipro Software Support

The latest build of this product (v22.1.3) was released 18 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.