/// <summary> /// Populates the page with content passed during navigation. Any saved state is also /// provided when recreating a page from a prior session. /// </summary> /// <param name="sender"> /// The source of the event; typically <see cref="NavigationHelper"/> /// </param> /// <param name="e">Event data that provides both the navigation parameter passed to /// <see cref="Frame.Navigate(Type, object)"/> when this page was initially requested and /// a dictionary of state preserved by this page during an earlier /// session. The state will be null the first time a page is visited.</param> private async void NavigationHelper_LoadState(object sender, LoadStateEventArgs e) { // TODO: Create an appropriate data model for your problem domain to replace the sample data //var item = await SampleDataSource.GetItemAsync((string)e.NavigationParameter); var item = await SampleDataSource.GetItemAsync((int)e.NavigationParameter); this.DefaultViewModel["Item"] = item; //get the categoryname for this recipe var categoryId = item.Category_Id; var category=await SampleDataSource.GetGroupAsync(categoryId); var categoryName = category.Name; //display the category name for this recipe in RecipeCategoryName textblock RecipeCategoryName.Text = "Cusine : " + categoryName; //To show rating as the number of stars //Text="{Binding Items[0].Rating}" var rating = item.Rating; var ratingtext = ""; for (int i = 0; i < rating; i++) { //draw as many stars as the rating in the textblock for rating ratingtext += "*"; } RecipeRating.Text = "Rating : " + ratingtext; }
/// <summary> /// Populates the page with content passed during navigation. Any saved state is also /// provided when recreating a page from a prior session. /// </summary> /// <param name="sender"> /// The source of the event; typically <see cref="NavigationHelper"/> /// </param> /// <param name="e">Event data that provides both the navigation parameter passed to /// <see cref="Frame.Navigate(Type, object)"/> when this page was initially requested and /// a dictionary of state preserved by this page during an earlier /// session. The state will be null the first time a page is visited.</param> private async void NavigationHelper_LoadState(object sender, LoadStateEventArgs e) { // TODO: Create an appropriate data model for your problem domain to replace the sample data. //var group = await SampleDataSource.GetGroupAsync((string)e.NavigationParameter); var group = await SampleDataSource.GetGroupAsync((int)e.NavigationParameter); this.DefaultViewModel["Group"] = group; }
/// <summary> /// Populates the page with content passed during navigation. Any saved state is also /// provided when recreating a page from a prior session. /// </summary> /// <param name="sender"> /// The source of the event; typically <see cref="NavigationHelper"/> /// </param> /// <param name="e">Event data that provides both the navigation parameter passed to /// <see cref="Frame.Navigate(Type, object)"/> when this page was initially requested and /// a dictionary of state preserved by this page during an earlier /// session. The state will be null the first time a page is visited.</param> private async void NavigationHelper_LoadState(object sender, LoadStateEventArgs e) { // TODO: Create an appropriate data model for your problem domain to replace the sample data //var group = await SampleDataSource.GetGroupAsync((string)e.NavigationParameter); var group = await SampleDataSource.GetGroupAsync((int)e.NavigationParameter); this.DefaultViewModel["Group"] = group; //display the subtitle for toprated section topRatedSubtitle.Text = "Top Rated "+ group.Name + " Recipe:"; this.DefaultViewModel["Items"] = group.Items.OrderBy(item => item.Id); // group.Items; //.Where((item) => item.Id.Equals(1)) //To show rating as the number of stars //Text="{Binding Items[0].Rating}" var rating = group.Items.First().Rating; var ratingtext = ""; for(int i=0;i<rating;i++) { //draw as many stars as the rating in the textblock for rating ratingtext += "*"; } //topRatedRatingText.Text = "Rating: #" + group.Items.First().Rating.ToString(); topRatedRatingText.Text = "Rating: " + ratingtext; //To display the preparation time for top rated recipe topRatedPrepTimeText.Text = "Preparation Time : " + group.Items.First().PreparationTime.ToString() +" minutes."; }
/// <summary> /// Populates the page with content passed during navigation. Any saved state is also /// provided when recreating a page from a prior session. /// </summary> /// <param name="sender"> /// The source of the event; typically <see cref="NavigationHelper"/> /// </param> /// <param name="e">Event data that provides both the navigation parameter passed to /// <see cref="Frame.Navigate(Type, object)"/> when this page was initially requested and /// a dictionary of state preserved by this page during an earlier /// session. The state will be null the first time a page is visited.</param> private async void NavigationHelper_LoadState(object sender, LoadStateEventArgs e) { // TODO: Create an appropriate data model for your problem domain to replace the sample data var sampleDataGroups = await SampleDataSource.GetGroupsAsync(); this.DefaultViewModel["Groups"] = sampleDataGroups; //International Cusine //var groups = await SampleDataSource.GetGroupsAsync(); //this.DefaultViewModel["Section2Items"] = groups; }
/// <summary> /// Populates the page with content passed during navigation. Any saved state is also /// provided when recreating a page from a prior session. /// </summary> /// <param name="sender"> /// The source of the event; typically <see cref="NavigationHelper"/> /// </param> /// <param name="e">Event data that provides both the navigation parameter passed to /// <see cref="Frame.Navigate(Type, object)"/> when this page was initially requested and /// a dictionary of state preserved by this page during an earlier /// session. The state will be null the first time a page is visited.</param> private async void NavigationHelper_LoadState(object sender, LoadStateEventArgs e) { // TODO: Create an appropriate data model for your problem domain to replace the sample data //featured recipe var sampleDataItem = await SampleDataSource.GetItemAsync(GetRandomNumber(25));//gets a recipe data with random recipeId this.DefaultViewModel["Section1Item"] = sampleDataItem; //International Cusine var groups = await SampleDataSource.GetGroupsAsync(); this.DefaultViewModel["Section2Items"] = groups; //var sampleDataGroup = await SampleDataSource.GetGroupAsync("Group-4"); //gets the top rated cusine on a random basis and displays the collection of its recipes var sampleDataGroup = await SampleDataSource.GetGroupAsync(GetRandomNumber(5)); this.DefaultViewModel["Section3Items"] = sampleDataGroup; }