Set Checked Resource Items in Code Behind

5 posts, 1 answers
  1. Daniel
    Daniel avatar
    9 posts
    Member since:
    Oct 2006

    Posted 30 Aug 2012 Link to this post

    Hi,
    I try to attach some default values to certain categories, i.e. when the user selects "Category1" in the CategoryCombo, the "Subject", "Body" etc. in the current appointment should be filled with a default text/values.

    Now to my problem:
    As soon as a category entry is selected, I'd like to "preselect" the default resources in the drop down "Personen" (see screenshot attached).

    I've attached an event handler "PART_Categories_SelectionChanged "to the CategoryCombo. Is there a way to access the checkedItems in the resources drop down in order to set the default selection from code behind?

    Thank you four your help!

    Regards
    Daniel
  2. Vladi
    Admin
    Vladi avatar
    744 posts

    Posted 04 Sep 2012 Link to this post

    Hi Daniel,

    You shouldn't have any issue when attaching events to the control in the EditAppointmentDialog. All that is needed is to customize the EditAppointmentDialogStyle and add the needed event to the RadComboBox with x:Name="PART_Categories", and in the event handler cast the sender object as RadComboBox in order to get the SelectedItem.

    I created and attached a sample project for you to take a look at. Give it a try.

    Greetings,
    Vladi
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. UI for WPF is Visual Studio 2017 Ready
  4. Daniel
    Daniel avatar
    9 posts
    Member since:
    Oct 2006

    Posted 04 Sep 2012 Link to this post

    Hi Vladi,

    thank you for your help.
    Obviously, I was not clear enough with my question. What I'd like to achieve is to "preselect" some items not in the category dropdown but in the resources dropdown labeled "Personen" (sorry for that "messy" screen shot...). 
     That is, as soon as the pinkish category "... Singen"  is picked, the resources "Gabriel..", "Stefan..." and "Thomas..." in the "Personen" dropdown should be selected.
    The items in this drop down are bound via ResourceTypesSource to the "standard" EF tables ResourceType and Resource, respectively.

    Hope, this clarifies my question.

    Regards,
    Daniel
  5. Answer
    Vladi
    Admin
    Vladi avatar
    744 posts

    Posted 05 Sep 2012 Link to this post

    Hello Daniel,

    In that scenario first you will need to:
    1. Cast the DataContext of the ComboBox as AppointmentDialogViewModel in the SelectionChanged event.
    2. Find the ResourceType that you want to preselect and cast it as ResourceTypeViewModel.
    3. Finally change the SelectedItem of that ResourceType to the Item that you want to be preselected.

    We edited and attached the sample project for you.

    Hope this helps.

    All the best,
    Vladi
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  6. Daniel
    Daniel avatar
    9 posts
    Member since:
    Oct 2006

    Posted 06 Sep 2012 Link to this post

    Hello Vladi,

    thank you for your examples. With some slight modifications, I was even able to preselect the resources marked with "AllowMultipleSelection".

    Best regards,
    Daniel
Back to Top
UI for WPF is Visual Studio 2017 Ready