首页 > 解决方案 > 如何解析 ShellViewModel (Caliburn.Micro) 中的设置对象

问题描述

我有一个字典对象定义如下

        Dictionary<string, object> dictArguments = new Dictionary<string, object>();
        dictArguments.Add("CommandLine", strCommandLineArguments);

然后我将它传递给 ShellViewModel,如下所示。

        DisplayRootViewFor<ShellViewModel>(dictArguments);

而我不知道 ShellViewModel 如何以及在何处解析此参数,因为就 Caliburn 而言,ShellViewModel 有一个带有 ieventAggregator 的 CTOR。请问有什么指点吗?

谢谢,

迪帕克

标签: caliburn.micro

解决方案


DisplayRootViewFor 的参数接受 Windows 设置作为字典。例如,

Dictionary<string, object> dictArguments = new Dictionary<string, object>();
dictArguments.Add("Height", 1000);
dictArguments.Add("Width", 1500);
dictArguments.Add("ShowInTaskbar", false);
dictArguments.Add("WindowStartupLocation", WindowStartupLocation.CenterScreen);
DisplayRootViewFor<ShellViewModel>(dictArguments);

这些设置会影响 View 的 Height、Width、ShowInTaskbar 和 WindowStartupLocation 属性(Caliburn Micro 会这样做,您不需要手动进行)。

我认为这对存储 CommandLine 参数没有用。


推荐阅读