【发布时间】:2013-03-07 04:18:26
【问题描述】:
我正在尝试使用 Caliburn 和以下代码绑定组合框:
yyyView.xaml
<ComboBox x:Name="Filters"></ComboBox>
yyyViewModel.xaml
private string selectedFilter;
public BindableCollection<string> Filters
{
get
{
return new BindableCollection<string>(
new string[]{ "All", "Last Month", "Last Week", "Yesterday" });
}
}
public string SelectedFilter
{
get { return selectedFilter; }
set
{
selectedFilter = value;
NotifyOfPropertyChange(() => SelectedFilter);
}
}
使用此代码,我在 App.xaml.cs 上收到 ArgumentNullException strong>GetInstance 方法。
我是 MVVM、Caliburn 和 XAML 的新手,但我在某处读到过某些行为(我相信是混合行为)在 WinRT 开发中下降。
是这个问题吗?我该如何解决这个问题?
谢谢
编辑:
App.xaml.cs
protected override void Configure()
{
LogManager.GetLog = type => new DebugLogger(type);
container = new WinRTContainer();
container.RegisterWinRTServices();
container.PerRequest<aaaViewModel>();
container.PerRequest<xxxViewModel>();
container.PerRequest<yyyViewModel>();
container.PerRequest<zzzViewModel>();
}
App.xaml
<caliburn:CaliburnApplication
x:Class="yyyStoreApp.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:yyyApp"
xmlns:caliburn="using:Caliburn.Micro"
xmlns:converters="using:yyyApp.Converters"
RequestedTheme="Light">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Resources/CustomStyles.xaml" />
<ResourceDictionary Source="Resources/StandardStyles.xaml"/>
</ResourceDictionary.MergedDictionaries>
<converters:ImageFilePathConverter x:Key="ImageFilePath"/>
</ResourceDictionary>
</Application.Resources>
</caliburn:CaliburnApplication>
【问题讨论】:
-
你能发布你的 App.xaml 和任何相关的代码隐藏吗?听起来有些东西没有正确构建,尽管您的 Caliburn 绑定。
-
我没有为此视图更改 App.xaml,并且该应用程序的其他视图正在运行。在后面的代码中我已经注册了 ViewModel:
container.PerRequest<yyyViewModel>();我可以进入视图并查看其他绑定的元素,只有组合框无法正常工作。它是空的,当我单击它时会引发异常。
标签: mvvm windows-8 windows-store-apps winrt-xaml caliburn.micro