This is a migrated thread and some comments may be shown as answers.

Trouble with binding (SelectedValue)

4 Answers 115 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Trude
Top achievements
Rank 2
Trude asked on 20 Aug 2010, 02:11 PM

I'm having some trouble with bind the RadComboBox properly - can you please give some input on this scenario:

I have a listbox which is bound to a collection of main_items
When a selection is made in the listbox I set the datacontext of the radcombobox to the listbox's selecteditem.
Basically I want to change a property in main_items with a the selected value in the radcombobox.
The radcombobox correctly lists all detail_items, but here the trouble starts.

The following radcombobox/code does not update the temp_id column of main_items properly when a selection is made
(sporadically it works, but when the datacontext changes all is lost) Is there something I have overlooked?

<telerik:RadComboBox ItemsSource="{Binding sub_items}" DisplayMemberPath="detail_name" SelectedValuePath="detail_id" SelectedValue="{Binding temp_id, Mode=TwoWay}">
</telerik:RadComboBox>

Public Class main_items
    Public Property main_id As Guid
    Public Property main_name As String
    Public Property sub_items As EntityCollection(Of detail_items)
    Public Property temp_id as Guid
End Class

Public Class detail_items
    Public Property detail_id as Guid
    Public Property detail_name as String
End Class

 

4 Answers, 1 is accepted

Sort by
0
Trude
Top achievements
Rank 2
answered on 20 Aug 2010, 03:09 PM
Update ... I found the cause of my problems; actually the class main_items looks like this:

Public Class main_items
    Public Property main_id As Guid
    Public Property main_name As String
    Public Property sub_items As EntityCollection(Of detail_items)
    
Public Property temp_id as Nullable(Of Guid)
End Class

When temp_id is set to nullable the code does not work. If I remove the nullable attribute everything works as expected. Is this by design or have I found a bug?
0
Konstantina
Telerik team
answered on 24 Aug 2010, 02:33 PM
Hello Jorn,

Thank you for contacting us.

I have made a sample project in which I tried to reproduce the described behaviour, but to no avail. Attached I am sending you this project. Please feel free to modify it in order to reproduce the issue and send it back to us. In that way we will be able to track down the source of the problem in a timely manner.

Please let us know if you have further questions.

Greetings,
Konstantina
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Trude
Top achievements
Rank 2
answered on 25 Aug 2010, 07:16 AM

Thanks for putting together a project that clearly illustrates the problem (with a small modification!)

In your DataViewModel you create your (dummy) value like such:

data1.Text_id = New Guid(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)

 

 

 

So, when you run the application and select a value you will see a blank Guid (all zeroes). All seems well, but it's not. If you replace that line with: 

 

 

 

data1.Text_id = Guid.NewGuid

You would expect to see a random Guid when you select a value from the combobox, no? The fact is that the binding is not working and you see all zeroes like before.

I think the binding breaks when one or more Temp_id's (in the DataViewModel) contains a null value. If they are all non-null the binding works fine.

Edit: formatted code as code block

0
Konstantina
Telerik team
answered on 30 Aug 2010, 08:15 AM
Hello Jorn,

Thank you for your  reply.

The mistake is mine. Please accept my appologies. As I initially created the sample project in C# I have omitted to set the GET and SET methods and to implement the PropertyChanged. I am sending you again the project with this corrections made.
Please feel free to modify it in order to reporduce the issue.

Please let me know if you have any other questions about our controls.

Best wishes,
Konstantina
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
ComboBox
Asked by
Trude
Top achievements
Rank 2
Answers by
Trude
Top achievements
Rank 2
Konstantina
Telerik team
Share this question
or