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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T19:33:39+00:00 2026-06-11T19:33:39+00:00

Hi I am trying to study the data binding property in windows phone. I

  • 0

Hi I am trying to study the data binding property in windows phone. I googled and got some blogs. As learned from those blogs I binded values in a ListBox. Now the listbox showng many products with name, amount , date, image properties. But now I am trying to do this, if click on any product in the list I want to navigate to other page and display the product details there. But in that page the databinding is not working. Just those textblocks shows nothing. I included my code below. Please help me to find the problem in my code.

Transaction.cs

public class Transaction
{
    public String Name { get; set; }
    public String Date { get; set; }
    public int Amount { get; set; }
    public String Type { get; set; }

    public Transaction(String name, String date, int amount,String type)
    {
        this.Name = name;
        this.Date = date;
        this.Amount = amount;
        this.Type = type;
    }
}

public class ShowItem 
{
    public String SelectedItemName { get; set; }
    public String SelectedItemImage { get; set; }
    public String SelectedItemDate { get; set; }
    public String SelectedItemAmount { get; set; }

    public ShowItem(String name, String date, String amount, String image)
    {
        this.SelectedItemName = name;
        this.SelectedItemDate = date;
        this.SelectedItemAmount = amount;
        this.SelectedItemImage = image;
    }
}

MainPage.xaml

<Grid  Height="530" Grid.Row="1" VerticalAlignment="Top" Margin="0,30,0,0">
            <ListBox Margin="0,0,0,0" Name="TransactionList">
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <Button  Width="460" Height="150" BorderThickness="0" Click="user_click" Name="rowButton" Background="{Binding Color}" >
                            <Button.Content>
                                <StackPanel Orientation="Horizontal" Height="auto" Width="400">
                                    <Image Width="80" Height="80" Source="{Binding Type}"></Image>
                                    <StackPanel Orientation="Vertical" Height="150" Margin="20,0,0,0">
                                        <StackPanel Orientation="Horizontal" Height="40">
                                            <TextBlock Width="100" FontSize="22" Text="Name :" Height="40" ></TextBlock>
                                            <TextBlock Width="auto" FontSize="22" Text="{Binding Name}" Height="40" ></TextBlock>
                                        </StackPanel>
                                        <StackPanel Orientation="Horizontal" Height="40">
                                            <TextBlock Width="100" FontSize="22" Text="Date :" Height="40" ></TextBlock>
                                            <TextBlock Width="100" FontSize="22" Text="{Binding Date}" Height="40" ></TextBlock>
                                        </StackPanel>
                                        <StackPanel Orientation="Horizontal" Height="40">
                                            <TextBlock Width="100" FontSize="22" Text="Amount :" Height="40" ></TextBlock>
                                            <TextBlock Width="auto" FontSize="22" Text="{Binding Amount}" Height="40" ></TextBlock>
                                            <TextBlock Width="auto" FontSize="22" Text=" $" Height="40" ></TextBlock>
                                        </StackPanel>
                                    </StackPanel>
                                </StackPanel>
                            </Button.Content>
                        </Button>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>
        </Grid>

MainPage.xaml.cs

public partial class MainPage : PhoneApplicationPage
{
    string[] _dates = { "19/9/1984", "25/8/1952", "27/5/1992", "4/8/1975", "10/3/2000", "22/1/2002", "23/5/2012", "25/9/1963", "13/7/1999", "15/4/1936" };

string[] _imageList = { "69290979.png", "acrobat-reader-cs-4.png","azureus-1.png","ClothDolls_lnx-Icons-Colored_Blue_Doll_256x256.png-256x256.png","database-27.png",
                          "documents-folder-2.png", "Front_Row_Icon.png","gear-8.png","info-chat.png","itunes-6.png","nero-smart-start-1.png",
                          "network-2.png","picasa.png","quicktime-7-red.png","twitter-bird.png","wlm-1.png" };


    string[] _items = { "Television", "Radio", "Fridge", "Fan", "Light", "Cup", "Plate", "Dress", "Laptop", "Mobile" };
    int[] _prices = { 10, 15, 20, 25, 30, 5, 8, 15, 10, 20 };

    List<Transaction> transactionList;

    // Constructor
    public MainPage()
    {
        InitializeComponent();

        Loaded += new RoutedEventHandler(MainPage_Loaded);
    }

 void MainPage_Loaded(object sender, RoutedEventArgs e)
    {
        int count = 50;
        String DefaultName = "";
        String DefaultDate = "";
        int DefaultAmount = 0;
        String DefaultImage = "";
        transactionList = new List<Transaction>();
        Random random = new Random();

        for (int i = 0; i < _items.Length; i++)
        {
            DefaultName = _items[i];
            DefaultDate = _dates[i];
            DefaultAmount = _prices[i];
            DefaultImage = "Images/" + _imageList[random.Next(0, _imageList.Length)];

            transactionList.Add(new Transaction(DefaultName, DefaultDate, DefaultAmount, DefaultImage));
        } 

        TransactionList.ItemsSource = transactionList;
   }

    private void user_click(object sender, RoutedEventArgs e)
    {
        var myData = ((Button)sender).DataContext as Transaction;
        NavigationService.Navigate(new Uri("/DisplayProduct.xaml?Name=" + myData.Name +"&Date=" + myData.Date + "&Amount=" + myData.Amount + "&Type=" + myData.Type, UriKind.Relative));
    }

}

DisplayProduct.xaml

<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
        <StackPanel Orientation="Vertical">
            <StackPanel HorizontalAlignment="Center">
                <Image Width="auto" Height="auto" Name="itemImage" Source="{Binding SelectedItemImage}"></Image>
            </StackPanel>
            <StackPanel Orientation="Horizontal">
                <StackPanel Orientation="Vertical" Width="350" HorizontalAlignment="Left">
                    <StackPanel Orientation="Horizontal" Margin="0,20,0,0">
                        <TextBlock Text="Name : " Width="150" Height="70" FontSize="35"  Foreground="DarkSalmon"></TextBlock>
                        <TextBlock Name="itemName" Text="{Binding SelectedItemName}" Width="auto" Height="70" FontSize="35"></TextBlock>
                    </StackPanel>
                    <StackPanel Orientation="Horizontal" Margin="0,20,0,0">
                        <TextBlock Text="Amount : " Width="150" Height="70" FontSize="35" Foreground="DarkSalmon"></TextBlock>
                        <TextBlock Name="itemPrice" Text="{Binding SelectedItemAmount}" Width="auto" Height="70" FontSize="35"></TextBlock>
                        <TextBlock Name="currency" Text="$" Width="auto" Height="70" FontSize="35"></TextBlock>
                    </StackPanel>
                    <StackPanel Orientation="Horizontal" Margin="0,20,0,0">
                        <TextBlock Text="Date : " Width="150" Height="70" FontSize="35" Foreground="DarkSalmon"></TextBlock>
                        <TextBlock Name="itemDate" Text="{Binding SelectedItemDate}" Width="auto" Height="70" FontSize="35"></TextBlock>
                    </StackPanel>
                </StackPanel>
            </StackPanel>
        </StackPanel>
    </Grid>

DisplayProduct.xaml.cs

public partial class DisplayProduct : PhoneApplicationPage
{
    public DisplayProduct()
    {
        InitializeComponent();
        Loaded += new RoutedEventHandler(DisplayProduct_Loaded);
    }

    void DisplayProduct_Loaded(object sender, RoutedEventArgs e)
    {
        string name = NavigationContext.QueryString["Name"];
        string date = NavigationContext.QueryString["Date"];
        string amount = NavigationContext.QueryString["Amount"];
        string type = NavigationContext.QueryString["Type"];

        ShowItem showItemClass = new ShowItem(name, date, amount, type);
    }

}
  • 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-11T19:33:40+00:00Added an answer on June 11, 2026 at 7:33 pm
    void DisplayProduct_Loaded(object sender, RoutedEventArgs e)
    {
        string name = NavigationContext.QueryString["Name"];
        string date = NavigationContext.QueryString["Date"];
        string amount = NavigationContext.QueryString["Amount"];
        string type = NavigationContext.QueryString["Type"];
    
        ShowItem showItemClass = new ShowItem(name, date, amount, type);
        DataContext = showItemClass;
    }
    

    You forgot to set the DataContext of the page. It doesn’t know where should it get data to display.

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

Sidebar

Related Questions

I am new in windows phone development. Now I am trying to study about
I'm trying to read from a file some data I already have and to
I am trying to study some aspects of ddd with the domain of a
I come from a Java background and I am now trying to study PHP
i've been trying to study for my finals by practicing classes and inheritance, this
I am trying to study shadow mapping in WebGL. I see same piece of
I'm trying to study the WCF Web Services but I'm a bit confused about
My question is deceptively simple, but I have lost several hours of study trying
I am trying to load a data file into mysql table using LOAD DATA
I am trying to generate an output XML file from a master xml file

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.