0

I'm practicing my programming skills on an app that has a pivot page with seven pivot items. Each item has five buttons. I want those buttons to lead the user to the same page but with different content depending on which button was pressed. I know that I have to use XML parsing to achieve this but I just don't know where to start.

The idea is to have one application page and parse the right image and audio file to it depending on what button was pressed on the pivot page.

Here's an example of the XML:

   <?xml version="1.0" encoding="utf-8" ?>
    <Exercises>
       <Exercise name = "Exercise 1">
         <image>/Images/ex1.jpg</image>
         <audio>/Audio/ex1.mp3</audio>
       </Exercise>
       <Exercise name = "Exercise 2">
         <image>/Images/ex2.jpg</image>
         <audio>/Audio/ex2.mp3</audio>
       </Exercise>
       <Exercise name = "Exercise 3">
         <image>/Images/ex3.jpg</image>
         <audio>/Audio/ex3.mp3</audio>
       </Exercise>
       <Exercise name = "Exercise 4">
         <image>/Images/ex4.jpg</image>
         <audio>/Audio/ex4.mp3</audio>
       </Exercise>
       <Exercise name = "Exercise 5">
         <image>/Images/ex5.jpg</image>
         <audio>/Audio/ex5.mp3</audio>
       </Exercise>
    </Exercises>
Darren Burgess
  • 4,200
  • 6
  • 27
  • 43

1 Answers1

1

I am not sure where exactly you're stuck. One SIMPLE process to achieve this is:

  1. Create your buttons and seven pivots. Use Expression blend.
  2. You can have individual Click event handlers. Or, you can put the property of the button like "Exercise 1" or something that fits your case in the Tag. Use a single event handler for Click on all buttons, then depending on what (sender as Button).Tag gives you, Navigate by adding appropriate values to the query parameters.
  3. Parse the xml document, search this website or google for examples. You could use LINQ to use your data structures. See this for an example
  4. Display the appropriate content, by finding the values of audio and image using the exercise values which you can collect by NavigationContext.QueryString["exercise"], or whatever you named your query parameter.

I hope this helps you get started. Of course, there are many better approaches to this. Questions with the code that you tried will help you get specific responses.

Community
  • 1
  • 1
abhinav
  • 3,199
  • 2
  • 21
  • 25
  • Thanks man! I've already done point 1 and 2. The parsing is the what holds me back. But I'll continue to search for the answer. Thanks once again for the taking the time to reply!! – Allan Haapalainen Dec 23 '11 at 13:40
  • 1
    Happy to help. I've added an example's link. Hope that helps. In your case, when compared to the question in the link, it should not be so complex, since, you just need to get string values. – abhinav Dec 23 '11 at 13:49
  • Finally succeeded at parsing the images to the page. :) The NavigationContext.QueryString is giving troubles though – Allan Haapalainen Dec 23 '11 at 16:42