views:

42

answers:

1

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.

+1  A: 

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.

Doobi
I was thinking I would have to go down the path of creating a custom control, or something to that effect. Is this what you're referring to? http://msdn.microsoft.com/en-us/library/system.windows.data.ivalueconverter%28VS.95%29.aspx
Evil Pigeon
Yay it works! Thanks a heap. I had an issue where it was running the convert function before the lookup had been loaded (Due to the asynchronous nature of RIA services). I managed to get around this by raising the property changed event of the Id column.
Evil Pigeon