【问题标题】:Caliburn.micro View ViewModel name resolution issueCaliburn.micro 查看 ViewModel 名称解析问题
【发布时间】:2012-06-18 23:39:54
【问题描述】:

我在 View.xaml 和 View.cs 上使用名为 ComShorCaliburnWPF.ViewModules.Views.ShortMenuWindows.GWDSCT 的命名空间,用于我的 ViewModel.cs 和我使用的 IoC 容器 ComShorCaliburnWPF.ViewModules.Views.ShortMenuWindows.GWDSCT。当我最后删除 GWDSCT 时,它可以正常工作,但在当前状态下却不行。我希望它能够像现在这样工作,因为它准确地反映了文件的位置。有什么建议吗?

【问题讨论】:

  • 您能否添加更多细节,也许是代码示例?

标签: c# mvvm caliburn.micro


【解决方案1】:

有助于调试这些问题的一件事是使用记录器:

 public class DebugLogger : ILog
    {
        private readonly Type _type;

        public DebugLogger(Type type)
        {
            _type = type;
        }

        public void Info(string format, params object[] args)
        {
            if (format.StartsWith("No bindable"))
                return;
            if (format.StartsWith("Action Convention Not Applied"))
                return;
            Debug.WriteLine("INFO: " + format, args);
        }

        public void Warn(string format, params object[] args)
        {
            Debug.WriteLine("WARN: " + format, args);
        }

        public void Error(Exception exception)
        {
            Debug.WriteLine("ERROR: {0}\n{1}", _type.Name, exception);
        }
    }

然后在AppBootstrapper,配置方法。

LogManager.GetLog = type => new DebugLogger(type);

【讨论】:

  • 不确定为什么投反对票,记录器会告诉你为什么它无法解析名称。
  • 你说得对,记录器会有所帮助。但是您可以添加更多细节,例如将调试器注入 caliburn 微型引擎。由于您的答案缺乏细节,因此很明显被否决了。
  • 就是这样LogManager.GetLog = type => new DebugLogger(type); 除非改了,有一段时间没用了。
猜你喜欢
  • 1970-01-01
  • 2017-02-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-02-02
  • 1970-01-01
  • 1970-01-01
  • 2019-06-17
相关资源
最近更新 更多