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

  • Home
  • SEARCH
  • 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 8039217
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T03:30:09+00:00 2026-06-05T03:30:09+00:00

i am binding data to listbox in wp7 here is the code <ListBox x:Name=list_budget

  • 0

i am binding data to listbox in wp7

here is the code

              <ListBox x:Name="list_budget" Width="440">
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <TextBlock Name="txtname" Text="{Binding category}"></TextBlock>

                        </DataTemplate>
                    </ListBox.ItemTemplate>
                </ListBox>

//class function

    public string[] jinal;

    public void  budgetcategorywise()
    {

        var q = from shoppingItem p in db.Item1
                group p by new { p.category_name } into g
                select new { category = g.Key, total = g.Sum(p => p.total_amt) `enter code here`}.ToString();

      jinal = q.toarray();
}

//coding

        list_budget.ItemsSource = App.Viewmod.jinal;

now,the error is query is ok result is perfact but i am not able to bind the data to listbox.

  • 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-06-05T03:30:11+00:00Added an answer on June 5, 2026 at 3:30 am

    Looking at your code sample:

    1. Please make sure budgetcategorywise() is called before you do the binding
    2. Please change your binding to:

       <TextBlock Name="txtname" Text="{Binding}"></TextBlock>
      

    The reason for this second change is that your code uses a ToString() in the Linq list generation – which means that the class with its category field is flattened in a string represenation.


    If you wish to keep the category field in your binding then use a class for your list items like:

       public class MyListItem
       {
           public string category { get;set; }
           public double total { get;set; }
       }
    
       public List<MyListItem> jinal;
    
       public void  budgetcategorywise()
       {
    
            var q = from shoppingItem p in db.Item1
                    group p by new { p.category_name } into g
                    select new MyListItem() { category = g.Key, total = g.Sum(p => p.total_amt) };
    
          jinal = q.ToList();
       }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code for xaml section <ListBox Margin=0,0,-12,0 Visibility=Visible ItemsSource={Binding QuestionsCurrent.Answers}> <ListBox.ItemTemplate> <DataTemplate>
I have the following XAML: <ListBox HorizontalAlignment=Left Margin=0,6,0,10 Name=listBox1 Width=468 ItemsSource={Binding} Grid.ColumnSpan=1> <ItemsControl.ItemTemplate> <DataTemplate>
First, here is the previous post that deals with the ListBox AccountListBox data binding
if I'm using a ListBox for data binding, the listbox generates a listboxitem for
I'm using data binding and trying to implement editable table (listbox) in ZK. <listbox
I use data binding to display values in text boxes in a C# Windows
I'm trying to bind a ListBox's SelectedItem data to a property. The following code
I am trying to delete items from listbox which is data bound. Here is
I have a list box in WPF as under <ListBox Name=lstName DisplayMemberPath =ListName ToolTip={Binding
I have a problem with control visibility in listbox itemtemplate. Following is my code

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.