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

combox in window

9 Answers 102 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
xiaofeng
Top achievements
Rank 1
xiaofeng asked on 09 Jul 2009, 03:38 AM
I new a window like this in a button click event
RadWindow owin = new RadWindow(); 
owin.Content = new test(); 
owin.Show(); 
then in my test.xaml,there is a combox.I bind it like this
cboSearchBy.Items.Add(new RadComboBoxItem() { Name = "10214", Content = "First Name" }); 
cboSearchBy.Items.Add(new RadComboBoxItem() { Name = "10215", Content = "Last Name" }); 
I click the button ,and open a window,change the selected item of the combox.That's ok the first time.But I click the button second time,and do the same thing ,I will crashed. I do not know why ?I think the binding method of the combox is not right.But document of telerik say this:
RadComboBox combo1 = new RadComboBox(); 
combo1.Items.Add(new RadComboBoxItem() { Content = "Arial" }); 
combo1.Items.Add(new RadComboBoxItem() { Content = "Courier" }); 
combo1.Items.Add(new RadComboBoxItem() { Content = "Verdana" }); 
combo1.Items.Add(new RadComboBoxItem() { Content = "Tahoma" }); 
Thank you!

9 Answers, 1 is accepted

Sort by
0
xiaofeng
Top achievements
Rank 1
answered on 09 Jul 2009, 06:15 AM
SOS
0
Accepted
Valeri Hristov
Telerik team
answered on 09 Jul 2009, 03:47 PM
Hello,

I answered your support ticket. In case anyone else has the same problem, basically all you need to do is to remove the Name setting in the code behind, or use the Tag property instead. Other option would be to databind the combobox as demonstrated in our online examples:
http://demos.telerik.com/silverlight/#ComboBox/DataBinding

Greetings,
Valeri Hristov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
xiaofeng
Top achievements
Rank 1
answered on 10 Jul 2009, 01:10 AM
You mean the Name property is the same.But the Names which I set are not the same .one is 10214,and the other is 10215
0
Valeri Hristov
Telerik team
answered on 10 Jul 2009, 07:17 AM
Hello xiaofeng,

I mean that the second instance of the Test UserControl has a combo box, containing items as the first instance of the Test control. To resolve the problem you should not set Name at all.

Best wishes,
Valeri Hristov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
xiaofeng
Top achievements
Rank 1
answered on 10 Jul 2009, 10:48 AM
It likes what  you said,the instance of the Test UserControl or the combox did not be destroyed after I close the window.Can I think this?Does it have any method to destroy the instance the window ,or the UserControl, or the combox after close the window?
Thank you!
0
Valeri Hristov
Telerik team
answered on 10 Jul 2009, 10:50 AM
Hi xiaofeng,

Unfortunately, I am not aware of other way to workaround this bug in Silverlight 2.

All the best,
Valeri Hristov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
xiaofeng
Top achievements
Rank 1
answered on 13 Jul 2009, 12:45 AM
Your attitude is not right.If the instance of the control is not destroyed ,the it will take up the resource of the computer.Does it?
0
Valeri Hristov
Telerik team
answered on 13 Jul 2009, 09:45 AM
Please, accept my apologies for the curt reply. I will try to explain a bit more - there is a bug in the Silverlight 2 Popup control, that mixes the namescopes of the loaded inside the Popup UserControls. Usually, each UserControl instance has a separate namescope, e.g. all Name attributes inside it are unique and do not collide with the Name attributes of other instances of the same UserControl, or other UserControls. However, there are some situations where the Silverlight 2 Popup "mixes" the namescopes of the UserControls that are placed inside it. This is the same problem you are experiencing. To avoid it, you should not set Name on the combo box items. If you need to keep some data for each combo box item in order to distinguish them, you could use the Tag property instead.  Other option would be to databind the combo box.

This bug is fixed in Silverlight 3.

All the best,
Valeri Hristov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
xiaofeng
Top achievements
Rank 1
answered on 14 Jul 2009, 10:49 AM
OK.Thank you.I am sorry too.
Tags
ComboBox
Asked by
xiaofeng
Top achievements
Rank 1
Answers by
xiaofeng
Top achievements
Rank 1
Valeri Hristov
Telerik team
Share this question
or