Thanks for your information. The problem here is because of ConverterParameter. With this combobox, its itemsource is {Binding Data, ElementName=CategorySource}}, so I want to same datasource will be passed to converter ConverterParameter:
Above code is not incorrect. With your example, you set ConverterParameter='ProductDictionaries.CategoriesLookup' }. In order to do in this way, need to create a separaty class to re-get the data.
But the data is already in loaded when it's bound to itemsource, it should have a way to pass this data from the context without extra code.
Like ConverterParameter={CategorySource}, or ConverterParameter={ItemSource}
So what's the solution? How to pass the param for ConverterParameter?
But the data is already in loaded when it's bound to itemsource, it should have a way to pass this data from the context without extra code.
As far as I know, there is not any way to do what you are trying to do. Thus, my extra class. Think of it as a transitory approach until Microsoft improves the Combobox in Silverlight, much like having to have client and server data model classes on each
side of the WCF boundary before RIA services.
If this has answered your question, please hit the Mark as Answered link. Thanks!
I would do some in-place editing tests to verify that your foreign key is being propagated back to the parent table if you change the selected item in the combobox..
If this has answered your question, please hit the Mark as Answered link. Thanks!
Kent, the approach you are taking of binding to the Data property of your declaratively created DDS is exactly what I'm trying to do, but for me it doesn't work. Bob Baker's sample won't compile because my RIA is too new, are you able to get this to work
with the latest version of RIA?
kent.zhou
Member
273 Points
913 Posts
how to bind lookup data source from ria service for combox in datagrid?
May 22, 2009 04:18 PM | LINK
DataGrid has template column for combobox:
<data:DataGrid x:Name="MyGrid" AutoGenerateColumns="False" CanUserSortColumns="True" Background="#bbffffff">
<data:DataGrid.Columns>
......
<data:DataGridTemplateColumn Header="Category" >
<data:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Grid>
<ComboBox x:Name="myList" DisplayMemberPath="Name"></ComboBox>
</Grid>
</DataTemplate>
</data:DataGridTemplateColumn.CellTemplate>
</data:DataGridTemplateColumn>
......
</data:DataGrid.Columns>
Then I want to bind a lookup data(Catregories) from ria service to this combobox, I tried to use domaindatasource in xaml as below:
<data:DataGrid x:Name="MyGrid" AutoGenerateColumns="False" CanUserSortColumns="True" Background="#bbffffff">
<riaControls:DomainDataSource x:Name="CategorySource" LoadMethodName="LoadCategories">
<riaControls:DomainDataSource.DomainContext>
<domain:myContext />
</riaControls:DomainDataSource.DomainContext>
</riaControls:DomainDataSource>
<data:DataGrid.Columns>
......
<data:DataGridTemplateColumn Header="Category" >
<data:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Grid>
<ComboBox x:Name="catCom" ItemsSource="{StaticResource CategorySource}" DisplayMemberPath="CategoryName">
</Grid>
</DataTemplate>
</data:DataGridTemplateColumn.CellTemplate>
</data:DataGridTemplateColumn>
......
</data:DataGrid.Columns>
Then run it, I got blank screen, not error, nor result. even other user control also are not rendered.
How to solve it? where is the mistake I made?
kent.zhou
Member
273 Points
913 Posts
Re: how to bind lookup data source from ria service for combox in datagrid?
May 22, 2009 04:29 PM | LINK
Figured out: should use following way for binding:
ItemsSource="{Binding Data, ElementName=CategorySource}"
kent.zhou
Member
273 Points
913 Posts
Re: how to bind lookup data source from ria service for combox in datagrid?
May 22, 2009 04:54 PM | LINK
Then I want to add a converter to this combobox
SelectedItem="{Binding CategoryID,Converter={StaticResource pcCpnverter},ConverterParameter={Binding Data, ElementName=CategorySource}}"
But I got following error:
Additional information: Unknown attribute SelectedItem on element ComboBox. [Line: 98 Position: 56]
I set pcConverter in app.xaml. Not sure if the error is because of Converter={StaticResource pcCpnverter},
or ConverterParameter={Binding Data, ElementName=CategorySource}
Help please.
bbakermai
Member
230 Points
151 Posts
Re: how to bind lookup data source from ria service for combox in datagrid?
May 22, 2009 05:53 PM | LINK
Complete walk-through and solution here.
Bob Baker
MicroApplications, Inc.
Orlando .Net Users' Group
kent.zhou
Member
273 Points
913 Posts
Re: how to bind lookup data source from ria service for combox in datagrid?
May 22, 2009 09:35 PM | LINK
Thanks for your information. The problem here is because of ConverterParameter. With this combobox, its itemsource is {Binding Data, ElementName=CategorySource}}, so I want to same datasource will be passed to converter ConverterParameter:
ConverterParameter={Binding Data, ElementName=CategorySource}}
Above code is not incorrect. With your example, you set ConverterParameter='ProductDictionaries.CategoriesLookup' }. In order to do in this way, need to create a separaty class to re-get the data.
But the data is already in loaded when it's bound to itemsource, it should have a way to pass this data from the context without extra code.
Like ConverterParameter={CategorySource}, or ConverterParameter={ItemSource}
So what's the solution? How to pass the param for ConverterParameter?
bbakermai
Member
230 Points
151 Posts
Re: how to bind lookup data source from ria service for combox in datagrid?
May 26, 2009 03:25 AM | LINK
As far as I know, there is not any way to do what you are trying to do. Thus, my extra class. Think of it as a transitory approach until Microsoft improves the Combobox in Silverlight, much like having to have client and server data model classes on each side of the WCF boundary before RIA services.
Bob Baker
MicroApplications, Inc.
Orlando .Net Users' Group
kent.zhou
Member
273 Points
913 Posts
Re: how to bind lookup data source from ria service for combox in datagrid?
May 27, 2009 10:27 PM | LINK
Thank for all your guys help. Finally, I got the solution:
1. Use CellTemplate and CellEditingTemplate.
2. Binding data in combobox loaded event.
No need to use Converter.
bbakermai
Member
230 Points
151 Posts
Re: how to bind lookup data source from ria service for combox in datagrid?
May 28, 2009 01:32 AM | LINK
I would do some in-place editing tests to verify that your foreign key is being propagated back to the parent table if you change the selected item in the combobox..
Bob Baker
MicroApplications, Inc.
Orlando .Net Users' Group
kent.zhou
Member
273 Points
913 Posts
Re: how to bind lookup data source from ria service for combox in datagrid?
May 28, 2009 02:00 PM | LINK
Thank you, Bob. Remember that putting Combobox in a DataForm and DataGrid is different because DataForm provides more CURD assistant internally.
PeterWone
Member
19 Points
8 Posts
Re: Re: how to bind lookup data source from ria service for combox in datagrid?
Jul 27, 2009 11:51 AM | LINK
Kent, the approach you are taking of binding to the Data property of your declaratively created DDS is exactly what I'm trying to do, but for me it doesn't work. Bob Baker's sample won't compile because my RIA is too new, are you able to get this to work with the latest version of RIA?