How to set CheckedItems in Windows

4 posts, 0 answers
  1. Miroslav
    Miroslav avatar
    30 posts
    Member since:
    Feb 2012

    Posted 11 Jun 2012 Link to this post

    Hello,

    I have a DataBoundListBox inside Window. After opening Window I need set CheckedItems in DataBoundListBox, but DataBoundListBox have no values. I tried it in event "WindowOpened". But in real I see all items in ListBox. How can I set CheckedItems so that it was after data binding?
    Same issue is in PickerBox...

    Thanks

    Miroslav Mareš
  2. Lancelot
    Lancelot avatar
    251 posts
    Member since:
    Jul 2012

    Posted 11 Jun 2012 Link to this post

    Hi Miroslav,

    It seems you are looking trying too early to set the checkbox's state, there isn't anything loaded in the listbox yet. Try to use the Loaded event for the RadDataBoundListBox instead. The same goes for the RadListPicker. Here is an example:

    <telerik:RadDataBoundListBox x:Name="myRadListBox" Loaded="myRadListBox_Loaded" >
       <your dataTemplate with checkbox and other goodies in here />
    </ telerik:RadDataBoundListBox>

    Use the control's loaded event instead of the window's loaded event. This way you should have access to the items in the listbox.

    Good Luck,
    Lancelot
  3. DevCraft banner
  4. Deyan
    Admin
    Deyan avatar
    2039 posts

    Posted 12 Jun 2012 Link to this post

    Hello Miroslav,

     Thanks for writing.

    Changing the checked/unchecked state of items in DataBoundListBox is done by modifying the contents of the CheckedItems collection. It is important to note that this collection is working only after you have bound the control to a data source so make sure that you do this in this sequence.

    I hope this helps.

    Kind regards,
    Deyan
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  5. Miroslav
    Miroslav avatar
    30 posts
    Member since:
    Feb 2012

    Posted 12 Jun 2012 Link to this post

    Hi Lancelot,

    this is, what I need.

    thanks

    Miroslav Mareš

Back to Top