C# 无法运行基于catel 4的简单应用程序
我试图运行一个基于catel 4的简单应用程序,但我甚至没有显示窗口。我没有错误或警告 下面是测试应用程序和应用程序本身的代码C# 无法运行基于catel 4的简单应用程序,c#,mvvm,catel,C#,Mvvm,Catel,我试图运行一个基于catel 4的简单应用程序,但我甚至没有显示窗口。我没有错误或警告 下面是测试应用程序和应用程序本身的代码 <catel:DataWindow x:Class="WpfApplication1.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
<catel:DataWindow x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:catel="http://catel.codeplex.com"
Title="MainWindow" Height="350" Width="525">
<Grid>
<CheckBox Content="Check me to continue" IsChecked="{Binding UserAgreedToContinue, NotifyOnValidationError=True, ValidatesOnDataErrors=True}" />
</Grid>
公共部分类主窗口:数据窗口
{
公共主窗口()
:base(DataWindowMode.Custom)
{
初始化组件();
}
}
公共类MainWindowViewModel:ViewModelBase
{
公共重写字符串标题{get{return“Just acknowledge”;}
公共bool用户同意继续
{
获取{返回GetValue(UserAgreedToContinueProperty);}
set{SetValue(UserAgreedToContinueProperty,value);}
}
公共静态只读属性data UserAgreedToContinueProperty=RegisterProperty(“UserAgreedToContinue”,typeof(bool));
}
我做错了什么?为什么连窗户都不打开呢?
启用调试日志侦听器:
public App()
{
#if DEBUG
LogManager.AddDebugListener();
#endif
}
它会立即向您显示出问题所在:
无法创建视图“WPFAApplication1.MainWindow”的视图模型
断然的。确保自定义IViewModelLocator或注册
手动查看和查看模型
这是因为您没有MVVM中通常使用的名称空间。当然可以,但由于您是初学者,我建议您采取以下措施:
public App()
{
#if DEBUG
LogManager.AddDebugListener();
#endif
}