Issue binding RadComboBox

6 posts, 1 answers
  1. Adam
    Adam avatar
    40 posts
    Member since:
    Dec 2011

    Posted 10 May 2012 Link to this post

    Hi all,

    I'm working with the RadComboBox that I've placed inside my RadGridView Data Column Header. I've tried all types of ways to bind this combo box without success. I'm wanting to bind from code behind and I'd like to bind to a list. My list if populated using WCF.

    When my list is populated with the WCF results I then try to set the combo box item source to my list but that's giving me the object reference not set to an instance.....error....

    Can you provide some code samples?

    Here is what I've tried so far:
    XAML for RadComboBox inside Header
    <telerik:GridViewDataColumn Width=".10*" Background="#6DFFFFFF">
         <telerik:GridViewDataColumn.Header>
               <telerik:RadComboBox x:Name="cboType" ItemTemplate="{StaticResource dropDownTemplate }">
                </telerik:RadComboBox>
          </telerik:GridViewDataColumn.Header>
    </telerik:GridViewDataColumn>

    C# (Just bare code to show you the data return and binding)
    void client_GetRotarySystemsCompleted(object sender, GetRotarySystemsCompletedEventArgs e)
            {
                try
                {
                    if (e.Cancelled == false && e.Error == null && e.Result != null)
                    {
                        DATASystem = e.Result;
                    }
                }
                finally
                {
                    AppBusy.SetNotBusy();
                }
                LoadCombo();
            }

            public void LoadCombo()
            {
                cboType.ItemsSource = from af in DATASystem
                                      select af.CAB;
            }       
  2. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 15 May 2012 Link to this post

    Hi Adam,

    Please find attached an example which demonstrates how you can populate the combobox in this case. Download it and give it a try.

    Greetings,
    Yana
    the Telerik team

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

  3. DevCraft banner
  4. Adam
    Adam avatar
    40 posts
    Member since:
    Dec 2011

    Posted 15 May 2012 Link to this post

    Thanks Yana,
    This works, however, can you show me an example where the RadComboBox itemsource is the return value from a WCF web service? Keep in mind, I want the RadComboBox inside the RadGridView column header.

    Thanks!
    Adam
  5. Answer
    Yana
    Admin
    Yana avatar
    4554 posts

    Posted 16 May 2012 Link to this post

    Hello Adam,

    The example I've sent uses Silverlight-enabled WCF service, please check the Web project - it is called SampleService.svc.

    Regards,
    Yana
    the Telerik team

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

  6. Adam
    Adam avatar
    40 posts
    Member since:
    Dec 2011

    Posted 16 May 2012 Link to this post

    Oops, You're correct. I'm sorry about that. Last question: I notice the class you use as the user control resource is in the same file as the user control, MainPage.XAML.

    I've tried to replicate what you're doing by adding a new class inside my user control but I'm not sure how I can add it as a resource as I'm getting an error stating that 'CLR URI refers to namespace that is not included in the assembly'. How are you not getting that same type of error?

    If I want the class inside the user control where the grid and drop-down list are located, how do I add that as a resource in the XAML so I can set the drop-down list item source?

    I hope I'm making sense here, I'm unclear as to how you're able to create a resource from the class that's inside your user control and I'm not.

    Thanks,
    Adam
  7. Adam
    Adam avatar
    40 posts
    Member since:
    Dec 2011

    Posted 16 May 2012 Link to this post

    I got it Yana. Thanks for all your help!

    Adam
Back to Top
DevCraft banner