combox in window

10 posts, 1 answers
  1. xiaofeng
    xiaofeng avatar
    60 posts
    Member since:
    Jun 2008

    Posted 08 Jul 2009 Link to this post

    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!
  2. xiaofeng
    xiaofeng avatar
    60 posts
    Member since:
    Jun 2008

    Posted 09 Jul 2009 Link to this post

    SOS
  3. Answer
    Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 09 Jul 2009 Link to this post

    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.
  4. xiaofeng
    xiaofeng avatar
    60 posts
    Member since:
    Jun 2008

    Posted 09 Jul 2009 Link to this post

    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
  5. Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 10 Jul 2009 Link to this post

    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.
  6. xiaofeng
    xiaofeng avatar
    60 posts
    Member since:
    Jun 2008

    Posted 10 Jul 2009 Link to this post

    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!
  7. Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 10 Jul 2009 Link to this post

    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.
  8. xiaofeng
    xiaofeng avatar
    60 posts
    Member since:
    Jun 2008

    Posted 12 Jul 2009 Link to this post

    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?
  9. Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 13 Jul 2009 Link to this post

    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.
  10. xiaofeng
    xiaofeng avatar
    60 posts
    Member since:
    Jun 2008

    Posted 14 Jul 2009 Link to this post

    OK.Thank you.I am sorry too.
Back to Top