Hi there,
I have what should hopefully be a fairly simple question. I have a combobox held within a dataform which is in edit mode. My combobox is bound and populated from an entity collection and is displaying the correct choices, only when I select one and save the changes back the combobox value comes back as null. My xaml code for the combobox is below, I simply want to retrieve the text value held in the combobox.
<toolkit:DataField Grid.Column="0" Grid.Row="2" Label="Category" HorizontalAlignment="Stretch" LabelVisibility="Visible" Mode="Auto" IsReadOnly="False"> <ComboBox Height="Auto" Width="Auto" HorizontalAlignment="Stretch" Name="CategoryCombo" VerticalAlignment="Stretch" SelectedValue="{Binding CATNAME_, Mode=TwoWay}" SelectedItem="{Binding CATNAME_, Mode=TwoWay}" > <ComboBox.ItemTemplate> <DataTemplate> <TextBlock Text="{Binding CATNAME_, Mode=TwoWay}" /> </DataTemplate> </ComboBox.ItemTemplate> </ComboBox> </toolkit:DataField>
Any help is greatly appreciated...
Answer: 1
You might need to write a converter for that. Which will return the desired Text for this.
Let me know if you want me to write the code for you.
Answer: 2
Check this
http://forums.silverlight.net/t/52497.aspx/1
Answer: 3
Below is the code I use to query the database to populate the combobox.
var GDCategoriesloadOperation = context.Load<GDCategory>(context.GetGDCategoriesbyClientandSchemeQuery(GlobalVariables.currentClientRef, GlobalVariables.selectedSchemeName)); GDCategoriesloadOperation.Completed += new EventHandler(GDCategoriesloadOperation_Completed);
private void GDCategoriesloadOperation_Completed(object sender, EventArgs e) { PolicyCategory = dataForm1_addMember.FindNameInContent("CategoryCombo") as ComboBox; PolicyCategory.ItemsSource = context.GDCategories; }
I can retrieve the value as GDCategories:3 which is the correct id for the item but obviously i'd like the text value. Funny I seem to find comboBoxes to be one of the most frustrating things in silverlight
Answer: 4
You are Binding only the CATNAME_ to your combo. How are you getting the ID? I did not see any ID field in the Binding.