本文介绍了将数据加载到CollectionViewSource的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我尝试使用下面的代码将数据加载到CollectionViewSource.但是它将引发异常.如何解决此问题?

Hi All,

I''ve try to load data to CollectionViewSource using below code.But it will throw exception.How can I solve this problem?

_CollectionViewSource = (CollectionViewSource)this.FindResource("EmpAttendanceViewSource");
            if (dtp_Date.SelectedDate != null)
            {
                var obj = from ea in db.EmployeeAttendances
                          join emp in db.Employees
                          on ea.EmployeeId equals emp.EmployeeId
                          where ea.InDate == dtp_Date.SelectedDate
                          select new { emp.EmployeeFirstName, ea.InTime, ea.OutTime, ea.NoOfHours };
                _CollectionViewSource.Source = (CollectionViewSource)obj;



例外是,
{"TwoWay或OneWayToSource绑定不适用于类型为''<> f__AnonymousType21`4 [System.String,System.DateTime,System.Nullable`1 [System.DateTime] ,System.Nullable`1 [System.Double]]''."

请帮帮我.
谢谢,
Chamara



Exception Is,
{"A TwoWay or OneWayToSource binding cannot work on the read-only property ''InTime'' of type ''<>f__AnonymousType21`4[System.String,System.DateTime,System.Nullable`1[System.DateTime],System.Nullable`1[System.Double]]''."

Please help me.
Thanks,
Chamara

推荐答案

<textbox text="{Binding Path=InTime, Mode=OneWay}" />


这篇关于将数据加载到CollectionViewSource的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 00:38