Silverlight / WPF - How to bind Employee details to silverlight Combobox EmpName ,empid ??

Asked By Ramesh Nalla on 07-Feb-12 01:29 AM
Hi All,

can any one please help me for this problem..


i want to bind EmpName and EmpId to silverlight combobox.. In Asp.net DataTextField and DataValueField properties are there for doing this but how to do in silverlight combobox..?


Waiting for your reply.


Thanks

Ramesh
D Company replied to Ramesh Nalla on 07-Feb-12 01:53 AM
hello friend,

try like this

<ComboBox Height="23"  HorizontalAlignment="Left"  SelectedValue="{Binding EmpID, Mode=TwoWay}"  SelectedValuePath="Content" Margin="126,54,0,0" x:Name="comboBox1"   VerticalAlignment="Top" Width="120" DisplayMemberPath="Content"> 
<ComboBox.Items> 
<ComboBoxItem x:Name="x" Content="test2"></ComboBoxItem>  
<ComboBoxItem x:Name="x2" Content="test">
</ComboBoxItem>
</ComboBox.Items>
</ComboBox>

here is a good Article on this

Regards
D
Mahendar Nanamala replied to Ramesh Nalla on 07-Feb-12 02:01 AM
Hi,
You can try below one
<ComboBox x:Name="cbb" Height="30"  Width="200"  DisplayMemberPath="State" SelectedValuePath="Id" />
Ramesh Nalla replied to Mahendar Nanamala on 07-Feb-12 02:09 AM
Hi Mahendar,

but SelectedValuePath property is not there in silverlight ...iam using silverlight version 3.


Regards
Ram