I have a Silverlight application which uses 2 separate databases. I have a situation where I have an Id column in one database, and the lookup table in another database. Obviously I cannot enforce this as a foreign key, and the Entity Framework will not let me build a single Entity Data Model for 2 databases, so I cannot define this relationship in the Model either.
When I display the Id Column from database 1, I would like to display a field from datab开发者_开发技巧ase 2.
Ideally I would like to define this relationship and use a binding path and (without having my Model aware of my ViewModel). A column that could be bound to like a combo box would also be good, e.g.
<data:DataGridTextColumn
Header="Project"
Binding="{Binding Path=ProjectId}"
ItemsSource="{Binding Path=DataSource.Projects, Source={StaticResource ViewModelProxy}}"
DisplayMemberPath="ProjectName"
/>
Any help, or criticisms of my approach would be appreciated.
Well my first thought is that you could create a custom valueConvertor?
Bind to the foreign key value, and pass the required property name as the converter parameter, and do the lookup in the converter.
精彩评论