全て、
ItemsSource=MyContext.Entity1.Local (ObservableCollection) にバインドされた DataGrid コントロールを持つ WPF アプリがあります。このアプリの内部には、次のような DataGridComboBoxColumn があります。
<DataGridComboBoxColumn Header="User"
SelectedValueBinding="{Binding Path=USR_ID, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"
SelectedItemBinding="{Binding Path=TBL_USR, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"
ItemsSource="{Binding Path=MyEntity.TBL_USR, UpdateSourceTrigger=PropertyChanged, 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 を使用しています。