嘿,我正在使用 MVVM 模式在 Windows Phone 8.1 中开发一个应用程序。我想从以下位置获取日期日期选择器 on the 日期更改事件在视图模型中。
运行程序后我收到此错误:
App1.exe WinRT 中第一次出现“Windows.UI.Xaml.Markup.XamlParseException”类型异常
信息: 无法将类型“%0”的实例添加到类型的集合中
“%1”。 [行:117 位置:97] 类型异常
App1.exe 中发生“Windows.UI.Xaml.Markup.XamlParseException”,但是
未在用户代码中处理 WinRT 信息:无法添加实例
将“%0”类型添加到“%1”类型的集合中。 [线路:117 位置:97]
附加信息:与此错误代码相关的文本可能
找不到。
我的看法是:
<DatePicker Grid.Row="1" Grid.Column="1"
VerticalContentAlignment="Center"
HorizontalContentAlignment="Center"
HorizontalAlignment="Left"
VerticalAlignment="Center" Margin="26,-0.333,0,0.5"
Date="{Binding Dates, Mode=TwoWay}">
<i:Interaction.Behaviors>
<core:EventTriggerBehavior EventName="DateChanged">
<core:InvokeCommandAction Command="{Binding InitializeExpenseListCommand}"/>
</core:EventTriggerBehavior>
</i:Interaction.Behaviors>
</DatePicker>
和视图模型:
public MainViewModel()
{
_dates = new DateTimeOffset(DateTime.Now);
}
private DateTimeOffset _dates;
public DateTimeOffset Dates
{
get { return _dates; }
set
{
_dates = value;
RaisePropertyChanged();
}
}
public ICommand InitializeExpenseListCommand
{
get { return new RelayCommand(InitializeExpenseList()); }
}
public Action InitializeExpenseList()
{
return () => Debug.WriteLine(_dates);
}
谁能帮我解决这个错误?
我的回答可能有点晚了,但如果您尝试添加的事件不存在或不受EventTriggerBehaviour
。支持的事件有:Tapped
, PointerPressed
, Loaded
, DataContextChanged
, Click
, Checked
, Unchecked
, SelectionChanged
, TextChanged
, Toggled
, NavigationCompleted
See https://msdn.microsoft.com/en-us/library/windows/apps/dn469361.aspx https://msdn.microsoft.com/en-us/library/windows/apps/dn469361.aspx
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)