Binding SelectedValue and SelectedValuePath to Sub-Object Property

2 posts, 0 answers
  1. Robert Kaucher
    Robert Kaucher avatar
    56 posts
    Member since:
    Oct 2010

    Posted 07 Jun 2012 Link to this post

    My page's data context is set to an Instance of a Project class and all of the other fields in the page are working properly. Each project has another class associated with it as a property. This represents data from another company that we are integrating into this page.
    I am attempting to bind to this sub object's TypeID property. Here is a sketch of the objects.
          public class Project
            public int Id { get; set; }
            public string ProjectName { get; set; }
            public ABCProject ABCProject { get; set; }
        public class ABCProject
            public int Id { get; set; }
            public int ABCProjectTypeId { get; set; }
            public ABCProjectType { get; set; }
        public class ABCProjectType
           public int ProjectTypeId { get; set; }
           public string TypeName { get; set; }

    Here is what my XAML looks like:

    <telerik:RadComboBox Grid.Column="2" Grid.Row="1" telerik:StyleManager.Theme="Metro" x:Name="ProjectTypeCombo"
                                     ItemsSource="{Binding ProjectTypePickList}"
                                     SelectedValue="{Binding ABCProject.ABCProjectTypeId, Mode=TwoWay}"

    The pick list is being bound properly. The issue is that the selected value and selected value path don't seem to be binding as I get a blank combobox when the page loads.

  2. Konstantina
    Konstantina avatar
    2332 posts

    Posted 11 Jun 2012 Link to this post


    The issue with the RadComboBox is when the items are not loaded at once before the ItemsSource is set, the SelectedValue property won't work properly, as it tries only once to select the item, which might not be the first one. So the solution is to make sure that all items are loaded before you set the ItemsSource. More on the issue you could find in this forum discussion:

    Hope this information helps. Please do not hesitate to contact us again if you have further questions.

    All the best,
    the Telerik team
    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
Back to Top