Combobox selecteditem in Solverlight WCF Ria Services project

I'm using VS2010 and SL4, and have added a comboxBox to my xaml page.

I've used ria services and dragged the source from the datasources list, onto the combobox. When I run the project, the combobox displays the correct list of names.

In code, I need to do two things:

1) Read the selecteditem of the comboxbox - Currently when I read the selecteditem.toString(), I get (tablename - 28(or22)), not the name that is displayed. This should be the name that is displayed in the combobox

2) I need to somehow add the Value to the combobox, as you could in ASP.NET, so I can retrieve the selecteditem,(Name) and the SelectedValue(Instance)

Is this possible?

Thanks
<ComboBox Canvas.Left="63" Canvas.Top="130" Height="23" x:Name="comboMeters" Width="229" DisplayMemberPath="FriendlyName" ItemsSource="{Binding ElementName=meterListDomainDataSource, Path=Data}" >
            	<ComboBox.Effect>
            		<DropShadowEffect/>
            	</ComboBox.Effect>
            </ComboBox>

Open in new window

LVL 1
wint100Asked:
Who is Participating?
 
CuteBugCommented:
You need to cast the SelectedItem to the type which is represented by the datasource. Then you can get the values.

Check this link

http://blogs.silverlight.net/blogs/msnow/archive/2008/09/29/silverlight-tip-of-the-day-48-how-to-implement-a-combobox.aspx
http://forums.silverlight.net/forums/p/39769/235001.aspx
0
 
wint100Author Commented:
in this example http://forums.silverlight.net/forums/p/39769/235001.aspx

What is the 'Name' property?
0
 
wint100Author Commented:
Oops, missed the class at the bottom of the page..

What about if I binding to a domainclass?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.