Likes

Windows App Lab@Home 6.

3. Ryan, an app developer, has been assigned the

3. Ryan, an app developer, has been assigned the


Solution;
CS code:

Select New
New Project
The New Project dialog box is displayed
Ensure that the Windows store node is selected under the visual C# node


Select Blank App(XAML)
ensure that the SolutionExplorer windows is open
Right-click the App1 folder
Select Add
Select Class
The Add New Item- App1 dialog box is displayed
Replace the existing text in the Name text box with App1
The App1.cs file is displayed



using system.Collections.objectModel;
namespace App1
{
     class NotesCollection
     {
      public sring ObservableCollection<Note> Note = new ObservableCollection<Note>
     }
     class Note
      {
       public string Title {get; set}
       public string Content {get; set}
       public Note(string Title, string Content)
       {
          this.Title = Title;
          this.Content = Content;
       }
      }
}

Contract the Assets folder

Double-click the MailPage.XAML file






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


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");
        }
    }
}







Rhea has designed an app that should convert the temperature specified in Celsius to the corresponding temperature in Fahrenheit and vice versa. The interface of the app is shown in the following figure. The Interface of the App Rhea wants to implement the following functionalities in the app:

Rhea has designed an app that should convert the temperature specified in Celsius to the
corresponding temperature in Fahrenheit and vice versa. The interface of the app is shown in the
following figure.

The Interface of the App
Rhea wants to implement the following functionalities in the app:
When the user enters temperature in the Celsius text box, the corresponding temperature in
Fahrenheit should be displayed in the Fahrenheit text box and vice versa.
If the value entered in a text box is deleted, the other text box is updated accordingly.
If the user enters any value other than a number or . (Dot) in one of the text boxes, the Invalid
input message should be displayed in the other text box.
However, while testing the app, Rhea finds that the Fahrenheit text box is not updated when a
number is entered in the Celsius text box and vice versa.
Help Rhea identify the reason behind this problem and provide the solution for the same.

Solution;
XAML Code:

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

    <Viewbox>
        <Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}" Height="900" Width="1600">
            <TextBlock Text="Celsius" FontSize="100" Margin="122,122,1002,668"></TextBlock>
            <TextBox x:Name="txtDegreeCelsius" FontSize="70" Margin="122,237,121,554" keyUp="txtDegreeCelsius_KeyUp"></TextBox>
            <TextBlock Text="Fahrenheit" FontSize="100" Margin="122,463,931,326"/>
            <TextBox x:Name="txtDegreeFahrenheit" FontSize="70" Margin="122,582,121,209" keyUp="txtDegreeCelsius_KeyUp" />
        </Grid>
    </Viewbox>

</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.Navigation;

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

namespace ConverterApp
{
    /// <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 txtDegreeCelsius_KeyUp(object sender, KeyRoutedEventArge e)
        {
         try
          {
              if (!string.IsnullOrEmpty(txtDegreeCelsius.Text.Trim()))
                  txtDegreeFahrenheit.Text = (Convert.ToDouble(txtDegreeCelsius.));
              else
                 txtDegreeFahrenheit.text = "";
          }
          catch (Exception ex)
           {
           txtDegreeFahrenheit.text ="Invalid input";
           }
        }
        
       private void txtDegreeCelsius_KeyUp(object sender, KeyRoutedEventArge e)
        {
         try
          {
              if (!string.IsnullOrEmpty(txtDegreeCelsius.Text.Trim()))
                  txtDegreeFahrenheit.Text = (Convert.ToDouble(txtDegreeCelsius.));
              else
                 txtDegreeFahrenheit.text = "";
          }
          catch (Exception ex)
           {
           txtDegreeFahrenheit.text ="Invalid input";
           }
        }        
        /// <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)
        {
        }
    }
}

No comments: