topicosdeantonhi.files.wordpress.com · Web viewY abrimos un archivo nuevo y seleccionamos...

7
Entorno de desarrollo IDES, SDK ejemplo en Microsoft Visual Studio 2010 Express para Windows Phone Alumna: María Antonia Rangel García. El primer paso es abrir Microsoft Visual Studio 2010 Express para Windows Phone. Y abrimos un archivo nuevo y seleccionamos Silverlight for Windows Phone y aplicación de Windows pone, después el nombre del archivo. En el segundo paso, seleccionamos clic derecho en el nombre y agregamos un nuevo elemento.

Transcript of topicosdeantonhi.files.wordpress.com · Web viewY abrimos un archivo nuevo y seleccionamos...

Page 1: topicosdeantonhi.files.wordpress.com · Web viewY abrimos un archivo nuevo y seleccionamos Silverlight for Windows Phone y aplicación de Windows pone, después el nombre del archivo.

Entorno de desarrollo IDES, SDK ejemplo en Microsoft Visual Studio 2010 Express para Windows Phone

Alumna: María Antonia Rangel García.

El primer paso es abrir Microsoft Visual Studio 2010 Express para Windows Phone. Y abrimos un archivo nuevo y seleccionamos Silverlight for Windows Phone y aplicación de Windows pone, después el nombre del archivo.

En el segundo paso, seleccionamos clic derecho en el nombre y agregamos un nuevo elemento.

Page 2: topicosdeantonhi.files.wordpress.com · Web viewY abrimos un archivo nuevo y seleccionamos Silverlight for Windows Phone y aplicación de Windows pone, después el nombre del archivo.

Enseguida nos muestra una pantalla en el cual seleccionamos el archivo XML y lo nombramos.

En el siguiente paso agregamos una referencia. Que es necesaria para el archivo.

Page 3: topicosdeantonhi.files.wordpress.com · Web viewY abrimos un archivo nuevo y seleccionamos Silverlight for Windows Phone y aplicación de Windows pone, después el nombre del archivo.

Eb esta imagen muestra las referencias que están disponibles y seleccionamos y a su vez agregamos System.xml.linq.

En el siguiente paso se agrega el código xml. Dicho codigo funciona para que se muestra en el navegador.

Page 4: topicosdeantonhi.files.wordpress.com · Web viewY abrimos un archivo nuevo y seleccionamos Silverlight for Windows Phone y aplicación de Windows pone, después el nombre del archivo.

En el siguiente paso, se escribe el siguiente código en la pestaña (MainPage.xaml.cs). Sirve para que funcione el código del xml.

using System;using System.Collections.Generic;using System.Linq;using System.Net;using System.Windows;using System.Windows.Controls;using System.Windows.Documents;using System.Windows.Input;using System.Windows.Media;using System.Windows.Media.Animation;using System.Windows.Shapes;using Microsoft.Phone.Controls;using System.Windows.Resources;using System.Xml.Linq;using System.Text;

namespace PhoneApp1{ public partial class MainPage : PhoneApplicationPage { // Constructor XElement mb_data; public MainPage() { InitializeComponent(); StreamResourceInfo SRI = Application.GetResourceStream(new Uri("/localxml;component/mybookhistory.xml", System.UriKind.Relative)); mb_data = XElement.Load(SRI.Stream); this.ManipulationStarted += new EventHandler<ManipulationStartedEventArgs>(MainPage_ManipulationStarted); } void MainPage_ManipulationStarted(object sender, ManipulationStartedEventArgs e) { StringBuilder SB = new StringBuilder(); SB.Append("###################################" + Environment.NewLine); SB.Append("Here Are Some Book History which is given below-->" + Environment.NewLine); SB.Append("Books-->" + Environment.NewLine); var mb = from item in mb_data.Elements("mybookhistory") select item; foreach (XElement eachmb in mb) { SB.Append("************************************************" + Environment.NewLine); SB.Append("Title--> " + eachmb.Element("title").Value + Environment.NewLine); SB.Append("Author--> " + eachmb.Element("author").Value); SB.Append(eachmb.Element("author").Element("first-name").Value + " " + eachbook.Element("author").Element("last-name").Value + Environment.NewLine); SB.Append("Rating--> " + eachmb.Element("rating").Value + Environment.NewLine); SB.Append("Price--> " + eachmb.Element("price").Value + Environment.NewLine); SB.Append("************************************************" + Environment.NewLine); } textBlock1.Text = SB.ToString(); } }

}

Page 5: topicosdeantonhi.files.wordpress.com · Web viewY abrimos un archivo nuevo y seleccionamos Silverlight for Windows Phone y aplicación de Windows pone, después el nombre del archivo.

En el siguiente paso, se escribe el siguiente código en el diseño MainPage.xaml) para que muestre los datos del archivo xml.

<phone:PhoneApplicationPage     x:Class="localxml.MainPage"    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"    mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="768"    FontFamily="{StaticResource PhoneFontFamilyNormal}"    FontSize="{StaticResource PhoneFontSizeNormal}"    Foreground="{StaticResource PhoneForegroundBrush}"    SupportedOrientations="Portrait" Orientation="Portrait"    shell:SystemTray.IsVisible="True">    <!--LayoutRoot is the root grid where all page content is placed-->    <Grid x:Name="LayoutRoot" Background="Transparent">        <Grid.RowDefinitions>            <RowDefinition Height="Auto"/>            <RowDefinition Heigbht="*"/>        </Grid.RowDefinitions>        <!--TitlePanel contains the name of the application and page title-->        <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">            <TextBlock x:Name="PageTitle" Text="My Local Xml" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}" FontFamily="Comic Sans MS">               <TextBlock.Foreground>                  <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">                    <GradientStop Color="Black" Offset="0" />                    <GradientStop Color="#FF73D07E" Offset="1" />                  </LinearGradientBrush>               </TextBlock.Foreground>            </TextBlock>        </StackPanel>        <!--ContentPanel - place additional content here-->        <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">            <TextBlock Height="555" HorizontalAlignment="Left" Margin="12,25,0,0" Name="textBlock1" Text="Click to see xml file information"                        VerticalAlignment="Top" Width="438" FontFamily="Comic Sans MS" FontSize="26">              <TextBlock.Foreground>                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">                    <GradientStop Color="Black" Offset="0" />                    <GradientStop Color="#FFA1DEE5" Offset="0.648" />                </LinearGradientBrush>              </TextBlock.Foreground>            </TextBlock>            <Grid.Background>                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">                    <GradientStop Color="Black" Offset="0" />                    <GradientStop Color="#FFFF59FF" Offset="1" />                </LinearGradientBrush>            </Grid.Background>        </Grid>    </Grid></phone:PhoneApplicationPage>

Page 6: topicosdeantonhi.files.wordpress.com · Web viewY abrimos un archivo nuevo y seleccionamos Silverlight for Windows Phone y aplicación de Windows pone, después el nombre del archivo.

En la siguiente imagen se muestra como se ejecuta en el navegador.