Click here to Skip to main content
15,899,475 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,

I have a Silverlight Window which has a ComboBox with a set of other fields.
I set the DataContext of the Window from the Silverlight Page.
all the Fields are mapped correctly, except for the ComboBox Column.
It always displays the First item in the ComboBox and not the SelectedItem.
I tried to set the ComboBox selectedvalue selected item and nothing seem to work.

Following is the code that i have written.
HTML
<ComboBox Name="cmbCodeParts"
     Width="120"
     HorizontalAlignment="Left"
     ItemsSource="{Binding ElementName=tblRecipe_CodePartsTypeDomainDataSource, Path=Data}"
     DisplayMemberPath="codePartsType"
     SelectedValuePath="codePartsTypeID"
     SelectedValue="{Binding codePartsTypeID,Mode=TwoWay}"/>


I have loaded the DomainDataSource for the combobox in the dataform content loaded event.

Does anybody have a good working sample of this? I would appreciate help correcting my code for any errors.
Posted
Updated 7-Feb-11 14:23pm
v2

Learning_abc wrote:
SelectedValue="{Binding codePartsTypeID,Mode=TwoWay}"/>


Does it your DataContext has codePartsTypeID as property?

You can add some debug converters to check it you get value (other than null). You have to check your Output Window too as all the Binding Errors are thrown there.

For Debugging DataBinding, you can read Debugging Trick in XAML DataBinding[^]

Mark it as answer if it is helpful
 
Share this answer
 
v2
Hi Venkatesh Mookkan,

Yes the DataContext has the codePartsTypeID property.
I added the Converter and i get no error message.
I don't understand what is wrong?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900