开发者

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜