From c0562205de38d55fd336ae042536f5abf8bc2863 Mon Sep 17 00:00:00 2001 From: Antony Male Date: Thu, 15 Jan 2015 09:33:09 +0000 Subject: [PATCH] If a conductor receives a new ActiveItem, and it's not active, it will deactivate that item This is needed because the item being activated might actually be in the closed state, and we'll need to bring it into the deactive state --- Stylet/ConductorAllActive.cs | 12 +++++++----- Stylet/ConductorBaseWithActiveItem.cs | 2 ++ 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Stylet/ConductorAllActive.cs b/Stylet/ConductorAllActive.cs index 3aea8db..c80a27d 100644 --- a/Stylet/ConductorAllActive.cs +++ b/Stylet/ConductorAllActive.cs @@ -79,12 +79,12 @@ namespace Stylet protected virtual void ActivateAndSetParent(IEnumerable items) { this.SetParent(items); - if (this.IsActive) + foreach (var item in items) { - foreach (var item in items.OfType()) - { - item.Activate(); - } + if (this.IsActive) + ScreenExtensions.TryActivate(item); + else + ScreenExtensions.TryDeactivate(item); } } @@ -144,6 +144,8 @@ namespace Stylet if (this.IsActive) ScreenExtensions.TryActivate(item); + else + ScreenExtensions.TryDeactivate(item); } /// diff --git a/Stylet/ConductorBaseWithActiveItem.cs b/Stylet/ConductorBaseWithActiveItem.cs index 8640808..ee53a68 100644 --- a/Stylet/ConductorBaseWithActiveItem.cs +++ b/Stylet/ConductorBaseWithActiveItem.cs @@ -46,6 +46,8 @@ namespace Stylet if (this.IsActive) ScreenExtensions.TryActivate(newItem); + else + ScreenExtensions.TryDeactivate(newItem); } this._activeItem = newItem;