从视图模型中打开新窗口

嗨,我有一个初学者的问题。我有shell(它是wpf窗口),在这个shell中是屏幕(它是用户控件/视图模型)。 我想从视图模型打开新窗口,而不是在shell中显示用户控件。 所以我创建了一个新窗口 - ChatView
<Window x:Class="Spirit.Views.ChatView"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
        xmlns:extToolkit="clr-namespace:Microsoft.Windows.Controls;assembly=WPFToolkit.Extended" Title="ChatView" Height="545" Width="763">
    <Grid Margin="4,4,4,4">
     </Grid>
</Window>
使用MEF导出ChatViewModel。
 public interface IChatViewModel
    {

    }

    [Export("ChatScreen",typeof(IChatViewModel))]
    public class ChatViewModel
    {

    }
在视图模型中我有这个方法: 有了ShowScreen课程,请帮我Mr.Marco Amendola。它看起来像这样:
public class ShowScreen : IResult
    {
        readonly Type _screenType;
        readonly string _name;

        [Import]
        public IShellViewModel Shell { get; set; }

        Action<object> _initializationAction = screen => { };

        public ShowScreen InitializeWith<T>(T argument) 
        {
            _initializationAction = screen =>
                                        {
                                            var initializable = screen as IInitializable<T>;
                                            if (initializable != null)
                                                initializable.Initialize(argument);
                                        };
        return this;
        } 

        public ShowScreen(string name)
        {
            _name = name;
        }

        public ShowScreen(Type screenType)
        {
            _screenType = screenType;
        }

        public void Execute(ActionExecutionContext context)
        {
            var screen = !string.IsNullOrEmpty(_name)
                ? IoC.Get<object>(_name)
                : IoC.GetInstance(_screenType, null);

            _initializationAction(screen);

            Shell.ActivateItem(screen);
            Completed(this, new ResultCompletionEventArgs());
        }

        public event EventHandler<ResultCompletionEventArgs> Completed = delegate { };

        public static ShowScreen Of<T>()
        {
            return new ShowScreen(typeof(T));
        }
    }
我的问题是,如果我尝试显示新窗口它不起作用,它只有在shell(窗口)中显示新的用户控件时才有效。 我想在skype中实现类似的行为。你有一个带有列表框的主窗口,双击项目并显示新的聊天窗口。 主窗口可以在聊天窗口上用EventAggregator发布,聊天窗口也可以在主窗口上发布。这是我的目标。 我知道我不能在显示新窗口时使用类ShowScreen。我想知道从视图模型创建新窗口和注入事件聚合器的正确方法是什么 对这个竞争模型。 有什么建议?感谢您的帮助和时间。     
已邀请:
你看过WindowManager.Show或WindowManager.ShowDialog吗? Rob在http://caliburnmicro.codeplex.com/wikipage?title=The%20Window%20Manager上有一个示例。您可以将此依赖项作为IWindowManager注入到视图模型中。     
我正在使用它。也许可以保存一个关于“代码在哪里?”的问题。 DialogHelper:
public class DialogHelper
{
    public void ShowDialog<T>(params Object[] param) where T : class
    {
        var windowManager = new WindowManager();
        T viewModel = Activator.CreateInstance(typeof(T), param) as T;

        windowManager.ShowWindow(viewModel);
    } 
}
如何使用: 没有构造函数参数:
Dialog.ShowDialog<TestTableViewModel>();
使用构造函数参数:
Dialog.ShowDialog<TestTableViewModel>(dt);
请注意,我没有使用MEF     

要回复问题请先登录注册