标签:datepicker windows-phone-8-1 xaml c mvvm
嘿,我正在使用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
标签:datepicker,windows-phone-8-1,xaml,c,mvvm 来源: https://codeday.me/bug/20191120/2046226.html
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。