所有,
我有一个WPF应用程序,其DataGrid控件绑定到ItemsSource = MyContext.Entity1.Local(这是一个ObservableCollection).
这个应用程序内部是一个DataGridComboBoxColumn,如下所示:
<DataGridComboBoxColumn Header="User" SelectedValueBinding="{Binding Path=USR_ID,UpdateSourceTrigger=PropertyChanged,Mode=TwoWay}" SelectedItembinding="{Binding Path=TBL_USR,Mode=TwoWay}" ItemsSource="{Binding Path=MyEntity.TBL_USR,Source={StaticResource VM}}" SelectedValuePath="USR_ID" displayMemberPath="USR_WINlogoN" />
我的问题是我收到以下错误:
System.Windows.Data Error: 1 : Cannot create default converter to perform 'two-way' conversions between types MyContextType.TBL_USR' and 'System.String'. Consider using Converter property of Binding. BindingExpression:Path=TBL_USR; DataItem='Entity1Cl_4FDC0A147BE18671D96960BD8695EC4E3656B773570659474EE4FF228884E823' (HashCode=7143675); target element is 'DataGridCell' (Name=''); target property is 'CellContent' (type 'String') System.Windows.Data Error: 5 : Value produced by BindingExpression is not valid for target property.; Value='System.Data.Entity.DynamicProxies.TBL_USR30704B5EF5DAA11FBF2C9B305F529659FBCF422ED6696643EDB375A5D77F5A96' BindingExpression:Path=TBL_USR; DataItem='Entity1Cl_4FDC0A147BE18671D96960BD8695EC4E3656B773570659474EE4FF228884E823' (HashCode=7143675); target element is 'DataGridCell' (Name=''); target property is 'CellContent' (type 'String')
我认为它与DynamicProxies有关,但我无法弄清楚导致这个问题的原因(.Local?),以及如何围绕这个进行编码(至少,不是没有使用TypeConverter和Reflection,哎呀).
这或者与WPF行为异常有关(但我在上面的标记中找不到任何地方,我试图将我的实体设置为字符串).
所以我问,有没有人知道我如何强制Entity1.Local [n] .TBL_USR只是一个TBL_USR,或者如果有另一种方式(没有反射)我可以设置我的SelectedItembinding?
谢谢.
我正在使用EF 4.4(数据库优先)和.Net 4.0.
解决方法
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。