private void ShowImages(ChildWindowEventArg args) { var childWindow = new ChildWindow { Content = args.View, DataContext = args.ViewModel }; PhotoViewModel photoViewModel = args.ViewModel as PhotoViewModel; Action hideWindows = () => childWindow.Hide(); if (photoViewModel != null) { photoViewModel.HideWindow = () => hideWindows(); } Action <object, KeyEventArgs> childWindowKeyUp = (sender, e) => { if (e.Key == Key.Escape) { hideWindows(); } }; childWindow.KeyUp += (sender, e) => childWindowKeyUp(sender, e); Action <ChildWindowScaleEventArgs> scaleCildWindow = x => childWindow.WindowState = x.FullScale ? WindowState.Maximized : WindowState.Normal; Func <ChildWindowScaleEventArgs, bool> canScaleCildWindow = x => x != null; Messenger?.Register(CommandName.SetPhotoWindowState, scaleCildWindow, canScaleCildWindow); childWindow.ShowDialog(); Messenger?.Unregister(CommandName.SetPhotoWindowState); childWindow.Close(); }