Evil Pigeon
Evil Pigeon

Reputation: 1976

Displaying related, but non-foreign key data in a Silverlight datagrid column

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 database 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.

Upvotes: 1

Views: 660

Answers (1)

Doobi
Doobi

Reputation: 4842

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.

Upvotes: 1

Related Questions