Monday 24 February 2014

Steve has to develop a Windows Store app for displaying the various dishes available in a restaurant. The expected interface of the app is shown in the following figure.

Steve has to develop a Windows Store app for displaying the various dishes available in a
restaurant. The expected interface of the app is shown in the following figure.
The Expected Interface of the App
It is expected that whenever an item is selected from the list present on the left side, the
corresponding information is displayed on the right side of the app page. However, Steve is not
able to implement this functionality in the app. When he selects an item from the list, he does not
see any information on the right side. Help Steve find out the reason and solution for the preceding
problem.

Solution:

XAML CODE:

"<Page
    x:Class="DishesApp.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:DishesApp"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">

    <Grid Background="#FFD007F0">
        <ListView  x:Name="lst" HorizontalAlignment="Left" Height="688" Margin="64,46,0,0" VerticalAlignment="Top" Width="337"  FontSize="24" SelectionChanged="lst_selectionChanged"  >

        </ListView>
        <Viewbox>
            <StackPanel x:Name="stk" Orientation="Vertical" Margin="722,10,100,34" Width="458">
                <Image x:Name="img" Source="" HorizontalAlignment="Left"  Margin="20,20,0,20" VerticalAlignment="Top" />
                <TextBlock x:Name="head" Text="" FontSize="40" Margin="20,20,62,20" FontWeight="Bold" />
                <TextBlock x:Name="para" TextWrapping="Wrap" Text="" FontSize="30" Margin="20,20,62,20"/>
            </StackPanel>
        </Viewbox>
    </Grid>
</Page>
"

--------------------------------------------------------------------------------------------------

CS CODE:
"using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Media.Imaging;
using Windows.UI.Xaml.Navigation;

// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238

namespace DishesApp
{
    /// <summary>
    /// An empty page that can be used on its own or navigated to within a Frame.
    /// </summary>
    public sealed partial class MainPage : Page
    {
        public MainPage()
        {
            this.InitializeComponent();
        }
         private void lst_selectionChanged(object sender, selectionChangedEventArgs e)
        {
           if (lst.selectionItem.Tostring() == "Burger")
            {
               img.Source = New BitmapImage(new Uri("ms-appx:///Assets/Burger.jpg"));
               head.Text = "Burger";
               pare.Text = "Fresh juicy has burgers at a pocket-friendly of"
            }
            else if (lst.SelectedItem.Tostring() == "Cheese Sandwich")
            {
               img.Source = New BitmapImage(new Uri("ms-appx:///Assets/Cheese Sandwich.jpg"));
               head.Text = "Cheese Sandwich";
               pare.Text = "Mouth-watering cheesy sandwiches at a price of 2$"
            }
             else if (lst.SelectedItem.Tostring() == "Noodles")
            {
               img.Source = New BitmapImage(new Uri("ms-appx:///Assets/Noodles.jpg"));
               head.Text = "Noodles";
               pare.Text = "Traditional Noodles at a price of 3$"
            }
             else if (lst.SelectedItem.Tostring() == "Pasta Salad")
            {
               img.Source = New BitmapImage(new Uri("ms-appx:///Assets/Pasta Salad.jpg"));
               head.Text = "Pasta Salad";
               pare.Text = "Zesty summary Pasta Salad at a price of 2$"
            }
             else if (lst.SelectedItem.Tostring() == "Pizza")
            {
               img.Source = New BitmapImage(new Uri("ms-appx:///Assets/Pizza.jpg"));
               head.Text = "Pizza";
               pare.Text = "Lip smscking classic pizza at a rate of 5$"
            }
           
            }
        }
        /// <summary>
        /// Invoked when this page is about to be displayed in a Frame.
        /// </summary>
        /// <param name="e">Event data that describes how this page was reached.  The Parameter
        /// property is typically used to configure the page.</param>
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            lst.Items.Add(" Burger");
            lst.Items.Add(" Cheese Sandwich");
            lst.Items.Add(" Noodles");
            lst.Items.Add(" Pasta Salad");
            lst.Items.Add(" Pizza");
        }
    }
}
"

No comments:

Post a Comment