Dec 29, 2010 at 5:05 PM
Edited Dec 29, 2010 at 5:34 PM
very happy if
explain the following
situations. I open new wpf window from main view model from method with shell view model.
I open new window and add reference on this window to dictionary. I use dictionary on control if is window active or not. My problem is :
I open new window, close this window and then I want reactivate this window but I dont’t know if I close window (click on X ) is only deactivate or "not alive".
public class ShellViewModel : Conductor<object>, IShellViewModel
private IWindowManager _windowManager;
private Dictionary<string, object> _activeChatScreen;
public ShellViewModel(IWindowManager windowManager)
_windowManager = windowManager;
_activeChatScreen=new Dictionary<string, object>();
//with this method I open new chat screen
public void ShowChatScreen(DetailData oponent, BitmapImage avatarImage)
//if dic doesn’t contains refrence on chat screen
//create chat screen
var chatScreen = IoC.Get<IChatViewModel>();
//init chat screen
//add reference on chat screen to dic
//dic contains refence on chat screen
var chatScreen= _activeChatScreen[oponent.Info.Nick] as ChatViewModel;
//chat screen is not active
//HERE I WOULD LIKE ACTIVE CHAT SCREEN
New screen is WPF window:
public class ChatViewModel : Screen, IViewModelIdentity, IHandle<Rp>
I would like achieve behavior like in this pseudocode:
public void ShowChatScreen(string SCREEN_ID)
//SHOW ON TOP
//SHOW ON TOP
Also I think possible solution can be remove reference from dictionary if screen is deactivated but I think I must use event aggregator and publish on shell view model message when is screen deactivated.
What is the best way in my solution?
I thinking about rewrite Close event for CHAT SCREEN - wpf window. Something like this:
public new void Close()
_mClose = true;
private void Window_Closing(object sender, CancelEventArgs e)
e.Cancel = true;
And on closing event only hide window no close definitly.