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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T19:21:52+00:00 2026-05-24T19:21:52+00:00

I have an XML file that is bound to a listbox as below. This

  • 0

I have an XML file that is bound to a listbox as below. This displays a list of 20+ auctions all with each of the following elements.

listBox1.ItemsSource = from TM in r.Root.Descendants(ns + "Listing")
                                   select new TradeItem
                                   {
                                       ImageSource = TM.Element(ns + "PictureHref").Value,
                                       Title = TM.Element(ns + "Title").Value,
                                       Region = TM.Element(ns + "Region").Value,
                                       PriceDisplay = TM.Element(ns + "PriceDisplay").Value,
                                       ListingId = TM.Element(ns + "ListingId").Value,
                                   };

I want the user to be able to click on one of the auctions and have that pass the Listingid from the auction to another page where I will use that Listingid eg.. 40008598 to display specfic details on that auction as per below:

WebClient Detail = new WebClient();
            Detail.DownloadStringCompleted += new DownloadStringCompletedEventHandler(Detail_DownloadStringCompleted);
            Detail.DownloadStringAsync(new Uri("http://api.trademe.co.nz/v1/Listings/" + ***listingid from other previous page selection*** + ".xml"));

void Detail_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
        {
            if (e.Error != null)
                return;

            var r = XDocument.Parse(e.Result);

            // Declare the namespace
            XNamespace ns = "http://api.trademe.co.nz/v1";
            ListingDetails.ItemsSource = from D in r.Descendants(ns + "ListedItemDetail").Take(20)
                                         select new TradeItem
                                         {
                                             ImageSource = D.Element(ns + "Photos").Element(ns + "Photo").Element(ns + "Value").Element(ns + "Medium").Value,
                                             Title = D.Element(ns + "Title").Value,
                                             Region = D.Element(ns + "Region").Value,
                                             PriceDisplay = D.Element(ns + "Body").Value,
                                             ListingId = D.Element(ns + "ListingId").Value,
                                             CloseDate = D.Element(ns + "EndDate").Value,
                                             BuyNow = D.Element(ns + "BuyNowPrice").Value,
                                             StartPrice = D.Element(ns + "StartPrice").Value,
                                         };

Updated Code with changes ##########################################

    First Page - View Auction Listings

   namespace TradeMe
{
    public partial class MainPage : PhoneApplicationPage
    {
        // Constructor
        public MainPage()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            WebClient Trademe = new WebClient();
            Trademe.DownloadStringCompleted += new DownloadStringCompletedEventHandler(Trademe_DownloadStringCompleted);
            Trademe.DownloadStringAsync(new Uri ("http://api.trademe.co.nz/v1/Search/General.xml?search_string=" + TradeSearch.Text));

            progressBar1.IsIndeterminate = true;
            progressBar1.Visibility = Visibility.Visible;


        }



        void Trademe_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
        {
            if (e.Error != null)
                return;

            var r = XDocument.Parse(e.Result);

            // Declare the namespace
            XNamespace ns = "http://api.trademe.co.nz/v1";
            listBox1.ItemsSource = from TM in r.Root.Descendants(ns + "Listing")
                                   select new TradeItem
                                   {
                                       ImageSource = TM.Element(ns + "PictureHref").Value,
                                       Title = TM.Element(ns + "Title").Value,
                                       Region = TM.Element(ns + "Region").Value,
                                       PriceDisplay = TM.Element(ns + "PriceDisplay").Value,
                                       ListingId = TM.Element(ns + "ListingId").Value,
                                   };

            progressBar1.IsIndeterminate = false;
            progressBar1.Visibility = Visibility.Collapsed;
        }



        public class TradeItem
        {
            public string Region { get; set; }
            public string ListingId { get; set; }
            public string PriceDisplay { get; set; }
            public string Title { get; set; }
            public string ImageSource { get; set; }
        }

        private void hyperlinkButton1_Click(object sender, RoutedEventArgs e)
        {
            NavigationService.Navigate(new Uri("/TestPage.xaml", UriKind.Relative));
        }

        private void eventhandler(object sender, SelectionChangedEventArgs e)

        {
            var item = (sender as ListBox).SelectedItem as TradeItem;

            if (item != null)
            {
                string id = TradeItem.ListingId.ToString();
                NavigationService.Navigate(new Uri("/TestPage.xaml?ListingId=" + id, UriKind.Relative));
            }
        }


        }


    }

Second Page View listing details ############################################

    namespace TradeMe
{
    public partial class TestPage : PhoneApplicationPage
    {
        public TestPage()
        {
            InitializeComponent();
        }

        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            if (NavigationContext.QueryString.ContainsKey("ListingId"))
            {
                var listingId = NavigationContext.QueryString["ListingId"];

                WebClient Trademe = new WebClient();
                Trademe.DownloadStringCompleted += new DownloadStringCompletedEventHandler(Trademe_DownloadStringCompleted);
                Trademe.DownloadStringAsync(new Uri("http://api.trademe.co.nz/v1/Search/General.xml?search_string=" + listingId + ".xml"));

                progressBar1.IsIndeterminate = true;
                progressBar1.Visibility = Visibility.Visible;
            }
        }

        void Trademe_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
        {
            if (e.Error != null)
                return;

            var r = XDocument.Parse(e.Result);

            // Declare the namespace
            XNamespace ns = "http://api.trademe.co.nz/v1";
            ListingDetails.ItemsSource = from TM in r.Root.Descendants(ns + "Listing")
                                   select new TradeItem
                                   {
                                       ImageSource = TM.Element(ns + "PictureHref").Value,
                                       Title = TM.Element(ns + "Title").Value,
                                       Region = TM.Element(ns + "Region").Value,
                                       PriceDisplay = TM.Element(ns + "PriceDisplay").Value,
                                       ListingId = TM.Element(ns + "ListingId").Value,
                                   };

            progressBar1.IsIndeterminate = false;
            progressBar1.Visibility = Visibility.Collapsed;
        }



        public class TradeItem
        {
            public string Region { get; set; }
            public string ListingId { get; set; }
            public string PriceDisplay { get; set; }
            public string Title { get; set; }
            public string ImageSource { get; set; }
        }

        private void hyperlinkButton1_Click(object sender, RoutedEventArgs e)
        {
            NavigationService.GoBack();
        }

        private void button4_Click(object sender, RoutedEventArgs e)
        {

        }


        }



    }
  • 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-24T19:21:53+00:00Added an answer on May 24, 2026 at 7:21 pm

    Add a SelectionChanged event handler to listBox1. In this handler do the following

    void ListBoxSelectionChanged(object sender, SelectionChangedEventArgs args)
    {
      var item = (sender as ListBox).SelectedItem as TradeItem;
    
      if(item != null) {
        string id = item.ListingId.ToString();
        NavigationService.Navigate(
          new Uri("/AuctionDetailsPage.xaml?ListingId=" + id, UriKind.Relative));    
      }
    }
    

    In AuctionDetailsPage.xaml.cs

    protected override void OnNavigatedTo( NavigationEventArgs e )
    {
      base.OnNavigatedTo( e );
    
      if( NavigationContext.QueryString.ContainsKey( "ListingId" ) ) {
        var listingId = NavigationContext.QueryString["ListingId"];
    
        // use WebClient to get the details
      }
    }
    

    Note that you can simply convert the listing ID to a string and append it to the Uri when navigating because the ID is numeric and so it will not contain any characters that will be considered invalid in a Uri. However, if you were appending some other string to the Uri query string you should do the following:

    NavigationService.Navigate(
      new Uri( String.Format( "/NewPage.xaml?queryString1={0}&queryString2={1}",
        Uri.EscapeDataString( item.param1 ),
        Uri.EscapeDataString( item.param2 ) ), UriKind.Relative ) );
    

    The above example shows how to pass multiple query strings to another page.

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

Sidebar

Related Questions

I have an XML file that starts like this: <Elements name=Entities xmlns=XS-GenerationToolElements> I'll have
I have an XML file that has a number of nodes, each of which
I have an xml file that looks like this: ... <e1> <e2> <e3>content1.1</e3> <e3>content1.2</e3>
I have an XML file that looks like this. <collections id=my collections> <category id=my
I have a XML file that looks like this <Licence> <Name>Test company</Name> <Version>1.1.1.1</Version> <NumberOfServer>2</NumberOfServer>
I have an XML file that looks like this: <country> <routes> <SourceCountry>Ireland</SourceCountry> <SourcePort>Larne</SourcePort> <DestinationCountry>UK</DestinationCountry>
I have an XML file that encodes a directed acyclic graph (DAG) that represents
I have an XML file that looks like <?xml version='1.0' encoding='UTF-8'?> <root> <node name=foo1
I have an XML file that is very long, but here is a shot
I have an XML file that lists a series of items, and the items

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.