Click here to Skip to main content
15,885,309 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
This is probably one of the dumbest questions asked here but I'm really stuck so if someone could shed some light I'd be more than thankful.

So I've been trying to develop a simple Windows Phone app which would act as a cookbook. I'm new to Windows Phone and C# (and app development for that matter) so data binding has been a bit of a mess since there aren't too many Windows Phone tutorials out there and I have yet to find one which shows how data binding between different pages works.

So here's what I'm trying to do:
1. I have a list box withe recipes that I call, well, recipes
C#
this.recipes.Items.Add(new Recipe("Cake"));
this.recipes.Items.Add(new Recipe("Bread"));
this.recipes.Items.Add(new Recipe("Mud Cake"));
this.recipes.Items.Add(new Recipe("Jam"));
this.recipes.Items.Add(new Recipe("Pie"));
this.recipes.Items.Add(new Recipe("Cookies"));
this.recipes.Items.Add(new Recipe("Panda"));


2. I also used the listBox's method to see when an item has been selected. If it get's selected it should navigate to the recipe's page with some basic details

C#
private void recipes_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            //If nothing is selected
            if (recipes.SelectedIndex == -1) {
                return;
            }
            /*Before navigating I should probably set the RecipeInfo.xaml to show the selected recipe's details - That's the problem */
            
            NavigationService.Navigate(new Uri("/RecipeInfo.xaml", UriKind.Relative));
            //Deselect
            recipes.SelectedIndex = -1;

        }


3. And here's the problem. I don't know how to bind the data so that the Recipe's name, description and ingredients would show on the RecipeInfo.xaml page.

(By the way if I didn't mention already, the Recipe has a name, description and ingredients, all three are strings)

One thing that really annoys me is that I know that the solution is probably ridiculously simple, I just don't know what it is. Any help whatosever would be really appriciated.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900