简体   繁体   English

无法在Xaml中引用设计时ViewModel

[英]Unable to reference a design-time ViewModel in Xaml

I've done this before, but not for some time and clearly I'm missing something. 我之前已经做过,但是已经有一段时间了,很明显我缺少了一些东西。

In short, I've got a design-time model that inherits from my real view model and sets some properties in the constructor. 简而言之,我有一个设计时模型,该模型继承自我的真实视图模型并在构造函数中设置了一些属性。

I'm importing the namespace in Xaml and IntelliSense is suggesting the desired class name, which leads me to believe my naming is error-free. 我正在Xaml中导入名称空间,并且IntelliSense会建议所需的类名,这使我相信我的命名是没有错误的。

Even after a clean/build, I'm getting an error saying that the referenced model doesn't exist. 即使经过清理/构建,我仍然收到一条错误消息,指出所引用的模型不存在。

I can refer to the model from a .cs using Aurora.UI.ViewModels.SecurityViewModel_DesignTime without issue. 我可以使用Aurora.UI.ViewModels.SecurityViewModel_DesignTime从.cs引用模型,而不会出现问题。

(In case it matters, this project has a target of x64. This is due to a dependency on an bit-dependent library. It's the only real difference I can point to when comparing to previous implementations). (如果要紧,这个项目的目标是x64。这是由于依赖于位依赖的库。这是与以前的实现比较时我可以指出的唯一真正的区别)。

The name "SecurityViewModel_DesignTime" does not exist in the namespace "clr-namespace:Aurora.UI.ViewModels" 名称“ SecurityViewModel_DesignTime”在命名空间“ clr-namespace:Aurora.UI.ViewModels”中不存在

屏幕截图显示了xaml,项目结构和异常

And the model itself: 和模型本身:

namespace Aurora.UI.ViewModels {
    public class SecurityViewModel_DesignTime : SecurityViewModel {
        public SecurityViewModel_DesignTime() {
            this.Sensor = new Peripherals.Kinect();
            this.PrimaryFeed = Kinect.Feed.Infrared;
            Feeds = new List<Kinect.Feed> {Kinect.Feed.Infrared};
            this.LookDirections = 
                Peripherals.Kinect.DirectionsRequired.Front | 
                Peripherals.Kinect.DirectionsRequired.Left | 
                Peripherals.Kinect.DirectionsRequired.Right | 
                Peripherals.Kinect.DirectionsRequired.Top;

        }
    }
}

(The class it's inheriting from is the 'real' viewModel and is a simple POCO) (它继承的类是“真实的” viewModel,是一个简单的POCO)

What am I missing? 我想念什么?

As per the comment, here's an answer: 根据评论,这是一个答案:

Do a solution clean, and restart visual studio. 清理解决方案,然后重新启动Visual Studio。 Goodness knows why it works. 天哪知道它为什么起作用。 The designer is janky at the best of times. 设计师在最好的情况下很简陋。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM