Mvvm Catel框架调试错误

Mvvm Catel框架调试错误,mvvm,catel,Mvvm,Catel,我试图学习Catel MVVM,通过获取最简单的Catel裸体示例来使用VS Express 2012并不断获得错误。我认为我的问题在于“使用”XAML中的语句、引用或头。一个自动生成的文件会在MainWindow.g.cs中写入如下所示的有问题的行。代码文件非常短,所以我已经包含了它们 模型、视图模型和视图分为三个项目,都在一个解决方案下 型号-暂时空白 ViewModel-MainWindowViewModel(还没有属性) 查看-MainWindow.xmal,MainWindow.xma

我试图学习Catel MVVM,通过获取最简单的Catel裸体示例来使用VS Express 2012并不断获得错误。我认为我的问题在于“使用”XAML中的语句、引用或头。一个自动生成的文件会在MainWindow.g.cs中写入如下所示的有问题的行。代码文件非常短,所以我已经包含了它们

模型、视图模型和视图分为三个项目,都在一个解决方案下

  • 型号-暂时空白
  • ViewModel-MainWindowViewModel(还没有属性)
  • 查看-MainWindow.xmal,MainWindow.xmal.cs(还没有控件或属性)

    我不断收到以下警告和伴随的错误:

    “c:…\MainWindow.g.cs”中的类型“Catel.Windows.DataWindow” 与中导入的类型“Catel.Windows.DataWindow”冲突 'c:…\Catel.MVVM.dll'。使用中定义的类型 'c:…\MainWindow.g.cs'

    错误是:

    Catel.Windows.DataWindow 过时:'请改用'Catel.Windows.DataWindow'。将 已在版本“4.0”中删除 C:…\MyFirstCatel\obj\Debug\MainWindow.g.cs

    namespace Catel.Windows {
        public partial class DataWindow : Catel.Windows.DataWindow<ViewModels.MainWindowViewModel>, System.Windows.Markup.IComponentConnector 
    {
         private bool _contentLoaded;
         ... code removed for post ....
    
    }
    
    MainWindow.xaml

    <Windows:DataWindow 
            x:Class="Catel.Windows.DataWindow"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"           
            xmlns:MainWindowViewModel="clr-namespace:ViewModels"
            xmlns:Windows="clr-namespace:Catel.Windows;assembly=Catel.MVVM"
           x:TypeArguments="MainWindowViewModel:MainWindowViewModel"
            Title="MainWindow" Height="350" Width="525">
        <Grid>
            <TextBlock>Hello world!</TextBlock>
        </Grid>
    </Windows:DataWindow>
    
    MainWindowViewModel.cs

    using System.Windows;
    using Catel.MVVM;
    
    namespace ViewModels
    {
        public class MainWindowViewModel : ViewModelBase
        {
            public MainWindowViewModel()
                : base()
            {
            }
    
            public override string Title { get { return "View model title"; } }
    
            public string Slug
            {
                get { return GetValue<string>(SlugProperty); }
                set { SetValue(SlugProperty, value); }
            }
    
            public static readonly Catel.Data.PropertyData SlugProperty = RegisterProperty("Slug", typeof(string), null);
    
        }
    }
    
    使用System.Windows;
    使用Catel.MVVM;
    命名空间视图模型
    {
    公共类MainWindowViewModel:ViewModelBase
    {
    公共主窗口视图模型()
    :base()
    {
    }
    公共重写字符串标题{get{return“视图模型标题”;}
    公共字符串段塞
    {
    获取{return GetValue(SlugProperty);}
    set{SetValue(SlugProperty,value);}
    }
    public static readonly Catel.Data.PropertyData SlugProperty=RegisterProperty(“Slug”,typeof(string),null);
    }
    }
    
    和在主窗口中

    namespace Catel.Windows {
        public partial class DataWindow : Catel.Windows.DataWindow<ViewModels.MainWindowViewModel>, System.Windows.Markup.IComponentConnector 
    {
         private bool _contentLoaded;
         ... code removed for post ....
    
    }
    
    名称空间Catel.Windows{
    公共部分类数据窗口:Catel.Windows.DataWindow、System.Windows.Markup.IComponentConnector
    {
    私有bool_内容加载;
    …已删除post的代码。。。。
    }
    

    }只有一件事是错的。在xaml定义中,您仍然使用指定vm类型的旧方法。删除x:TypeArguments,错误就会消失。

    WOW!非常感谢你的帮助!我就是那个给你发电子邮件介绍VS Express模板的人。我做了以下更改:删除了x:TypeArguments并添加了,但现在我在MainWindow中得到了一个循环引用。g.cs:Error 1循环基类依赖关系涉及“Catel.Windows.DataWindow”和“Catel.Windows.DataWindow”C:\…\MainWindow.I得到了进一步的修改:我更改了x:class=“MyFirstCatel.MainWindow”现在我得到了另一个错误,调用与指定绑定约束匹配的类型“MyFirstCatel.MainWindow”上的构造函数引发了一个异常…现在我得到了“DataWindow.cs not found您需要找到DataWindow.cs才能查看当前调用堆栈帧的源代码”。我已尝试更仔细地重新编写项目。我在DataWindow的构造函数上得到一个错误。public MainWindow():base()只需删除DataContext部分即可。卡特尔会自动完成这一切。你能提供关于这个错误的更多细节吗?