RIA Services Presentation Model with Combobox Lookups
I'm working on a Silverlight 4 WCF RIA Services app. I created a Presentation Model for my Stock entity, which is working fine. My trouble (well, one of my troubles) is when I try to databind a combobox to lookup a StockType.
I can set the combobox items source in xaml all OK (i.e. I can see the list of items in the dropdown), but the selected item is not bound to the CurrentStock.Type property. CurrentStock is a property on my viewmodel, and it's working fine for all the other fields, just not the comboboxes.
<Combobox
ItemsSource="{Binding Source={StaticResource StockTypeDataSource}, Mode=TwoWay}"
DisplayMemberPath="Type"
SelectedValue=="{Binding Path=CurrentStock.Type}"
SelectedValuePath="Type"/>
I believe this is because the combobox data source is in a different domain context to my StockPresentationModel entity, am I right? If so, can I work around that, or do I need to pull the Stock_Type entity into my Stock presentation model? Or can I somehow load my entities (Stock and Stock_Type) into my viewmodel and correctly set the combobox items source from there?
This is my first project using Silverlight and RIA, and I have hunted and searched and experimented for an embarrassing amount of ti开发者_Go百科me, so any help would be much appreciated.
Make sure that you have [Include] attribute in Type property in Metadata of entity class of RIA service.
精彩评论