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 9267727
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T14:37:17+00:00 2026-06-18T14:37:17+00:00

(Windows Phone 7 SDK) Hi, I have a ListBox named CTransactionList , and adding

  • 0

(Windows Phone 7 SDK)
Hi,
I have a ListBox named CTransactionList, and adding some items to this listbox by using data bindings. And Here I have a class to evaulate data bindings.(I think my listbox’s XAML code is not needed here as my issue comes out due to some coding problems)

public class CTransaction
    {
        public String Date1 { get; set; }
        public String Amount1 { get; set; }
        public String Type1 { get; set; }
        public CTransaction(String date1, String amount1, String type1)
        {
            this.Date1 = date1;
            this.Amount1 = amount1;
            switch (type1)
            {
                case "FR":
                    this.Type1 = "Images/a.png";
                    break;

                case "TA":
                    this.Type1 = "Images/b.png";
                    break;

                case "DA":
                    this.Type1 = "Images/c.png";
                    break;
            }
        }
    }

Here I have a function, when a move completes, this function runs;(this function is supposed to add new items when function runs)

List<CTransaction> ctransactionList = new List<CTransaction>();//Define my list

    public void movecompleted()
    {


        String DefaultDate = "";
        String DefaultAmount = "";
        String RandomType = "";

        DefaultDate = nameend.Text;
        DefaultAmount = diffend.Text;
        RandomType = "FR";

        ctransactionList.Add(new CTransaction(DefaultDate, DefaultAmount, RandomType));

        CTransactionList.ItemsSource = ctransactionList;
    }

For the first time when move completes, it adds the required elements to my list. But for next times, it does not add to my list. The old one keeps its existence. I tried also this format by getting list definition into my function like:

    public void movecompleted()
    {

        List<CTransaction> ctransactionList = new List<CTransaction>(); //List definition in function
        String DefaultDate = "";
        //...Same

}

And this time, it replaces my current item with new one. Do not append at the end of list. (Both ways, I have one item in my list, not more) How can I do everytime append to list? Where am I wrong?

Here is my Debugging report. Both ctransactionList object and CTransactionList ListBox have the needed items according to my observations in debug watcher. Only problem, CTransactionList cant refresh itself properly even if it has the resources retrieved from ctransactionList object.

Here is my XAML code for my relevant listbox.(IF NEEDED)

<Grid>
                <ListBox Name="CTransactionList" Margin="0,0,0,0"  >
                    <ListBox.ItemTemplate >
                        <DataTemplate>
                            <Button Width="400" Height="120"  >
                                <Button.Content >
                                    <StackPanel Orientation="Horizontal" Height="80" Width="400">
                                        <Image Source="{Binding Type1}" Width="80" Height="80"/>
                                        <StackPanel Orientation="Vertical" Height="80">
                                            <StackPanel Orientation="Horizontal" Height="40">
                                                <TextBlock Width="100" FontSize="22" Text="Name:" Height="40"/>
                                                <TextBlock Width="200" FontSize="22" Text="{Binding Date1}" Height="40"/>

                                            </StackPanel>
                                            <StackPanel Orientation="Horizontal" Height="40">
                                                <TextBlock Width="100" FontSize="22" Text="Difficulty:" Height="40"/>
                                                <TextBlock Width="200" FontSize="22" Text="{Binding Amount1}" Height="40"/>
                                            </StackPanel>
                                        </StackPanel>
                                    </StackPanel>
                                </Button.Content>
                            </Button>
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                </ListBox>

            </Grid>

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-06-18T14:37:18+00:00Added an answer on June 18, 2026 at 2:37 pm

    As you rightly mentioned, it’s not related to your XAML. Problem is in your code.

    First simple fix may to clear the ItemsSource before setting the new source, like this

    CTransactionList.ItemsSource = null;
    CTransactionList.ItemsSource = ctransactionList;
    

    This way, you are clearing the existing the databinding and enforcing the new list into the ListBox.

    The other and suggestible fix is,

    “Change your List to ObservableCollection. Because, ObservableCollection extends the INotifyPropertyChanged and hence has the ability to auto update the ListBox”

    List<CTransaction> ctransactionList = new List<CTransaction>();//Change this to below
    
    ObservableCollection<CTransaction> ctransactionList = new ObservableCollection<CTransaction>();//Define my collection
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Windows Phone app build using the 7.1 SDK that works great
I have the Dragon Mobile SDK running nicely on Windows Phone 7 and I
I am creating a windows phone application, which need to store some data in
I have The following problem: I use facebook-c#-sdk for windows phone 7.1(mango version), taken
My application for windows phone uses Microsoft Ad SDK and recently I have noticed
I have downloaded the Windows Phone SDK 8.0 from MS site. I have installed
I have a problem with Windows Phone 8 SDK. Accordign to MSDN, when I
I'm on a really bad internet connection, and I have Windows Phone 8 SDK
I have recently downloaded Windows Phone Toolkit ( November 2011, 7.1 SDK ) but
HI there, I'm playing around with the new Windows Phone 7 SDK and have

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.