Skip to main content
Home Forums Silverlight Programming WCF RIA Services Combobox Binding to SQL Database
3 replies. Latest Post by bbakermai on July 3, 2009.
(0)
Walesman
Member
0 points
7 Posts
07-02-2009 10:47 AM |
Could someone please provide or direct me to a 'simple' example of bindng data to a combobox. I have found many articles in various forums on binding to a combobox, but they all seem to deviate from the simple scenario I am trying to replicate.
I am using SL3, RIA Services, Entity Framework and the NorthWind DB. All I want to do is create a combobox and bind to the the 'CategoryName' column from the Categories table. I create the relevant Data Model, Service, Domain Data Source and bindins in xaml, but I dont get the correct content. What I see in the resulting combobox is
Category 1
Category 2
Category 3
etc
It appears to be a binding issue, but I am at a loss. If anyone has a simple example to show me the error of my ways I would greatly appreciate it.
Thanks
mchlsync
Star
14606 points
2,730 Posts
07-02-2009 2:48 PM |
Hello,
Are you seeing the type of object instead of CategoryName? I think you can try setting CategoryName to DisplayMemberPath of Combobox.
For example:
<
07-02-2009 5:45 PM |
Thanks for your response Michael. Actually, it was quiet simple in then end (see below) and I dont know what I was doing wrong.
In your xaml code, what does the 'DisplayMemeberPath' do differently from what I have below.
Phillip
<ComboBox x:Name="cmbCategories" Width="150" ItemsSource="{Binding}">
bbakermai
230 points
151 Posts
07-03-2009 6:46 PM |
Did you look at this blog post?