在Windows Phone 8.1 DatePicker中,无法将类型’%0’的实例添加到类型’%1’的集合中
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了在Windows Phone 8.1 DatePicker中,无法将类型’%0’的实例添加到类型’%1’的集合中,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1869字,纯文字阅读大概需要3分钟。
内容图文
嘿,我正在使用MVVM模式在Windows Phone 8.1中开发一个应用程序.我想从viewModel的DateChanged事件上的DatePicker获取日期.
运行程序后,我得到此错误:
A first chance exception of type ‘Windows.UI.Xaml.Markup.XamlParseException’ occurred in App1.exe WinRT
information: Cannot add instance of type ‘%0’ to a collection of type
‘%1’. [Line: 117 Position: 97] An exception of type
‘Windows.UI.Xaml.Markup.XamlParseException’ occurred in App1.exe but
was not handled in user code WinRT information: Cannot add instance of
type ‘%0’ to a collection of type ‘%1’. [Line: 117 Position: 97]
Additional information: The text associated with this error code could
not be found.
我的看法是:
<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>
和viewModel:
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不支持,则我的回答可能有点晚,但是会出现此错误(仍然)(在WinRT 8.1中消息中仍带有占位符!).支持的事件包括:轻击,PointerPressed,已加载,DataContextChanged,Click,选中,未选中,SelectionChanged,TextChanged,Toggled,NavigationCompleted
查看https://msdn.microsoft.com/en-us/library/windows/apps/dn469361.aspx
内容总结
以上是互联网集市为您收集整理的在Windows Phone 8.1 DatePicker中,无法将类型’%0’的实例添加到类型’%1’的集合中全部内容,希望文章能够帮你解决在Windows Phone 8.1 DatePicker中,无法将类型’%0’的实例添加到类型’%1’的集合中所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。