Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 987123
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T05:25:47+00:00 2026-05-16T05:25:47+00:00

I am currently trying to combine two collections into one for binding to a

  • 0

I am currently trying to combine two collections into one for binding to a combobox. I first started out with two static collections built within a class:

public partial class MainPage : UserControl
{
    //create static observable collection
    private ObservableCollection<string> items;

    public ObservableCollection<string> Items
    {
        get
        {
            return this.items;
        }
        set
        {
            if (this.items != value)
            {
                this.items = value;
            }
        }
    }

    protected ObservableCollection<string> StaticItems
    {
        get
        {
            return new ObservableCollection<string>() { "Select User", "Select All" };
        }
    }

    //create dynamic observable collection

    public MainPage()
    {
        InitializeComponent();
        this.items = this.StaticItems;
        this.comboBox1.ItemsSource = this.Items;
    }

    private void UserControl_Loaded(object sender, RoutedEventArgs e)
    {
        foreach (var item in GetDynamicItems())
        {
            this.Items.Add(item);
        }
    }

    private List<string> GetDynamicItems()
    {
        return new List<string>() { "User1", "User2", "User3" };

    }

The above works as desired.
What I would like to do now is to initate a query to a service and have the results of that service appended to the collection instead of User1, USer2,USer3

I create a query to the service as:

private void FillOfficerList()
{
    QueryClient qc = new QueryClient("BasicHttpBinding_IQuery");
    qc.GetOfficerNamesCompleted += new EventHandler<GetOfficerNamesCompletedEventArgs>(qc_GetOfficerNamesCompleted);
    qc.GetOfficerNamesAsync();
}

public void qc_GetOfficerNamesCompleted(object sender, GetOfficerNamesCompletedEventArgs e)
{
    // Now how do I add e.Results to above collection?
}

The query works I am just stuck on how to take the results ( e.Results) and bind/concat them to the Items collection. Any pointers or tips would be appreciated.

Note: This is for silverlight so using a composite collections approach does not seem to be an option as the class is not supported.

Thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T05:25:48+00:00Added an answer on May 16, 2026 at 5:25 am

    I just read your comment. Since you have the ObservableCollection with 3 strings and 1 int. Try doing this.

    Lets assume you are having a Class say myClass which has the 3 strings and 1 int.

    public class myClass()
    {
       string str1 {get; set;}
       string str2 {get; set;}
       string str3 {get; set;}
       int int1 {get; set;}
    }
    

    Create an ObservableCollection in the client side with the same datatype.

    ObservableCollection<myClass> collection = new ObservableCollection<myClass>();
    
    
    public void qc_GetOfficerNamesCompleted(object sender, GetOfficerNamesCompletedEventArgs e)   
    {   
     // Now try adding this code  
    for(int i=0; i<e.Result.Count;i++)  
    {  
         // I do this because, I don't want the Client class to be unaware of the class myClass
         collection.Add(new myClass()
               {
                 str1 = e.Result[i].str1,
                 str2 = e.Result[i].str2,
                 str3 = e.Result[i].str3,
                 int1 = e.Result[i].int1       
              });
    }   
    
    for(int i=0; i<collection.Count;i++)
    {
       Items.Add(collection[i].str1); // Add the string you want. I ve used str1 here.
    }
    
    }
    

    Hope this helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to add together two lists so the first item of one
Can I combine these 2 SQL statements? Currently running 2 queries. Trying to tighten
I'm currently trying out db4o (the java version) and I pretty much like what
I'm currently trying to get into the Java EE development with the Spring framework.
Trying to combine two htaccess RewriteRules at the same time: 1) transform all non-www
Currently, I'm trying to get all submissions from one user along with all comments
I am currently trying to use the XMLUnit library to compare two XML files.
I'm trying to combine the Address and Country Create Views into a single view.
I'm trying to combine code on two branches with the 'git merge' command, but
I am trying to use array_combine to combine two multi-dimensional arrays, but somehow not

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.