I get the following exception: "{System.ArgumentNullException: Value cannot be null.
Parameter name: Text" when setting the DataContext to null on a control, that contains some RadComboBoxes.
The stack trace:
at System.Windows.Controls.TextBox.set_Text(String value)
at Telerik.Windows.Controls.RadComboBox.TextUpdated(String newText, Boolean textBoxUpdated)
at Telerik.Windows.Controls.RadComboBox.OnTextChanged(String oldValue, String newValue)
at Telerik.Windows.Controls.RadComboBox.OnTextChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
at Telerik.Windows.PropertyMetadata.<>c__DisplayClass1.<Create>b__0(DependencyObject d, DependencyPropertyChangedEventArgs e)
at System.Windows.DependencyObject.RaisePropertyChangeNotifications(DependencyProperty dp, Object oldValue, Object newValue)
at System.Windows.DependencyObject.UpdateEffectiveValue(DependencyProperty property, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, ValueOperation operation)
at System.Windows.DependencyObject.RefreshExpression(DependencyProperty dp)
at System.Windows.Data.BindingExpression.SendDataToTarget()
I use a dataBinding to the Text property of the RadCombo:
Text="{Binding ParStyle, Converter={StaticResource StyleSelectionConverter}, Mode=TwoWay}"<br> |
Best regards
14 Answers, 1 is accepted
Thank you for your question.
We couldn't reproduce the error that you are getting. Attached I am sending you a sample project which I hope is pretty much what you are doing, illustrated in a simple way. If you are still facing difficulties please open a support ticket and send us a running project, which we can test locally.
Looking forward to your reply.
Best wishes,
Konstantina
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Ive updated my silverlight 3 business App to Silverlight 4. My RadComboBox is on a DataForm. When i press cancel, my command Rejects any changes to the WCF RIA Entity bound to the data form. As a result on the RejectChanges statement i get the exact error mentioned above. value cannot be null: parameter named text. The stack trace is also the same.
Please put the RadCombo Box on a dataform, bind its text property to a string value ( i also have a nulltoemptystringconverter which does not fire when calling reject changes but works fine otherwise ) and then make a sample to reproduce.
Regards.
Imran
Thank you for contacting us.
We tried to reproduce the problem, but we failed. Could you please send us a sample running project that illustrates the problem ? That should be very helpful to investigate the problem on our side.
I will be glad to assist you further.
George
the Telerik team
RadCombobox.TextProperty refuses to be bound to an empty or null string.
Highly annoying.
(Running latest version)
In order to bind Text property of the RadComboBox to a empty or null string, please make sure the RadComboBox is editable and you haven't set EmptyText property. If you set EmptyText property, its value will be applied, instead of empty string.
I hope this helps.
George
the Telerik team
I did what you said but it is still throwing exceptions.
I also cannot produce a sample project because these problems don't occur in sample projects. The error is random and generally incomprehensible. When I create little text cases like these:
RadComboBox b =
new
RadComboBox();
Binding binding =
new
Binding(
"emptytext"
);
binding.Source =
this
;
binding.Mode = BindingMode.TwoWay;
emptytext =
null
;
b.SetBinding(RadComboBox.TextProperty, binding);
...nothing seems to fail yet in my application I get this exception:
Message = Value cannot be null. Parameter name: Text (and my binding source its not null its empty string or "")
at System.Windows.Controls.TextBox.set_Text(String value)
Highly annoying problem that I cannot seem to figure out.
This issue obviously happens on some rare circumstances. We are really shooting in the dark here. All our attempts to reproduce the problem failed. We will greatly appreciate a project of yours that reproduces the problem.
George
the Telerik team
More documentation is needed on how RadComboBoxes "redo" their bindings when the binding's datacontext changes. The "cross" talk between SelectedItemProperty and TextProperty is caused by some sort of "non atomic" update of the bindings.
For example: If I set us up the bindings in the following order: ItemsSource, then SelectedItem and then TextProperty all works fine. If however I switch the order to ItemsSource, TextProperty and then SelectedItem I get all kinds of funny behavior including null exceptions and "cross" talk between entities. This behavior would not be strange if we can get some more documentation on it. How does the combobox update its bindings? Because if it went through it sequentially you can see all kinds of issues cropping up. In my case, when it gets to update the SelectedItemProperty from a new entity datacontext, the TextProperty feeds this update to the old entity because the two properties are connected.
So no big worries, but it can get confusing sometimes.
Thank you for your feedback, it helps us in improving our products. We will update our documentation about binding the RadComboBox according your suggestions.
Please do not hesitate to contact us if you require any further information.
Greetings,George
the Telerik team
I receive the same error in my project.
I have posted a small sample project as support ticket to reproduce the problem.
In this small application it is always reproducable.
Kind Regards.
Thank you for the sample application, it helped a lot. The quick workaround for the problem is to set FallbackValue='':
<telerik:RadComboBox Name="radComboBox1" DisplayMemberPath="FName" IsEditable="True" Text="{Binding FName, FallbackValue='', Mode=TwoWay}" >
The code above seems to fix the problem. I will log this issue for resolution, most probably the next week's internal build will contain the fix.
I apologize for the caused inconvenience.
Best wishes,
Valeri Hristov
the Telerik team
Thanks for the quick answer.
But I still receive an error when I rebind like this:
LayoutRoot.DataContext =
null
;
boundPerson =
null
;
...
boundPerson =
new
BoundPerson();
LayoutRoot.DataContext = boundPerson;
On the last code row I receive the same error.
Kind Regards.
I don't have a workaround for this problem. Fortunately the change that I made yesterday in RadComboBox seems to fix this problem too, so today's internal build should fix both of them.
Kind regards,
Valeri Hristov
the Telerik team