WIN10 IoT C # Development 1.5-three deployment methods for creating XAML-based UI programs and applications

Source: Internet
Author: User
Tags ftp client

Windows IoT Core is one of Microsoft's key products for the internet of things, and unlike previous versions of Windows, it is designed for IoT devices, and hardware is not limited to the x86 architecture, but can also be run on an arm architecture.

In the previous chapter we talked about Raspberry installation of the WIN10 IoT system and the way to build the visual Studio 2015 development Environment (HTTP://WWW.CNBLOGS.COM/CLOUDTECH/P/5562120.HTML), This time we'll look at how to deploy the Win10 IoT program to the raspberry environment.

Deploy using remote machine, Windows IoT Core Web Management, and Power shell commands three, respectively.

Preparatory work:

Raspberry Pi 2

Brush the Raspberry Pi 2 for the win IoT core system

Deploying a PC for the Visual Studio 2015 development environment

HDMI-enabled display

Goal: Demonstrate the success of your deployment by displaying the application's interface.

First create a Universal Windows application, open VS 2015 click New Project to find the Blank App in Visual C #-Windows-Universal (Universal Wi ndows) project template, select the template to enter the project name and click the OK button to create the project.

Modify the MainPage.xaml file of the main interface and add the TextBlock tag in the middle to display the start time. (XAML is an acronym for Extensible Application Markup language, used in WPF technology to define interface styles, and can implement the MVVM structure, Windows Universal Project The XAML in is equivalent to a subset of WPF to provide some functionality, and the content of the XAML is much more detailed in later chapters.

In order to simplify the MainPage.cs as a viewmodel, to implement the INotifyPropertyChanged interface to complete a simple MVVM framework.

Full code:

<page x:class= "Cloudtechiot1dot5.mainpage" xmlns= "http://schemas.microsoft.com/winfx/2006/xaml/presentation" x mlns:x= "Http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local= "using:cloudtechiot1dot5" xmlns:d= "http// schemas.microsoft.com/expression/blend/2008 "xmlns:mc=" http://schemas.openxmlformats.org/markup-compatibility/ 2006 "mc:ignorable=" D "> <Page.Resources> <style targettype=" TextBlock "> <setter Property= "HorizontalAlignment" value= "Center" ></Setter> <setter property= "VerticalAlignment" value= "Center" ></Setter> <setter property= "FontSize" value= "$" ></Setter> <setter Property= "FontWeight" value= "Bold" ></Setter> </Style> </Page.Resources> <!--HTTP://WW W.cnblogs.com/cloudtech [email protected]> <grid background= "{ThemeResource applicationpagebackground Themebrush} "> <grid.rowdefinItions> <RowDefinition></RowDefinition> <RowDefinition></RowDefinition> <RowDefinition></RowDefinition> </Grid.RowDefinitions> <textblock foreground= "LightBlue" text= "[email protected]" ></TextBlock> <textblock grid.row= "1" foreground= "Red" text= "{ Binding currenttime,updatesourcetrigger=propertychanged} "></TextBlock> <textblock grid.row=" 2 "Foregro Und= "Yellow" text= "Remote machine" ></TextBlock> </Grid></Page>

namespace cloudtechiot1dot5{    //http://www.cnblogs.com/cloudtech    //[email protected] public    sealed Partial class Mainpage:page, INotifyPropertyChanged    {public        event PropertyChangedEventHandler propertychanged;        private string _currenttime;        public string currenttime        {            get            {                return _currenttime;            }            Set            {                _currenttime = value;                Onproperitychanged ("CurrentTime");            }        }        Public MainPage ()        {this            . InitializeComponent ();            This. DataContext = this;            CurrentTime = DateTime.Now.ToString ("Yyyy-mm-dd HH:mm:ss");        }        public void Onproperitychanged (String propertyname)        {            propertychanged?. Invoke (PropertyName, New PropertyChangedEventArgs (PropertyName));}}}    

Connect the power and network cable to the raspberry and connect the HDMI display.

Power on the monitor displays the IP address of the current IoT device when the system boot is complete.

Let's deploy the IoT program below.

First approach: Remote machine Deployment

In the Visual Studio 2015 toolbar, select Remote Machine for debugging, and the IP address to enter the device's corresponding address. When you click Run, it is automatically deployed to your device.

The program starts to finish displaying the expected interface on the display.

Second approach: Windows IoT Core Web Management Deployment

To first package the program, in the Visual Studio 2015 solution Browser, right-click the item you want to package, and select Create App Packages in the Store menu item.

Choose No when asked if you want to upload to Windows store (we don't have this feature yet), Generate app bundle a choice of never.

Click the Next button to start compiling the file. The output path is displayed when the compilation is complete.

Open the browser to enter the IP address and port number of the IoT device into the Windows IoT core Web Management Login Interface (later we'll have articles specifically about Windows IoT core Web Management), enter the initial user name Admini Strator and password [email protected] Enter the main interface.

Select the Apps menu item in the menu on the left, and the App Manager panel will display information such as installed programs and programs running, the bottom of which is the Install app feature.

The APP package selects the. appx file under the published directory just now.

Click the Go button to start the installation program, after the installation is finished in installed apps, select the app you just installed, click the Start button to start the program, the program starts to complete the display display the expected interface. Clicking the Set Default button will set the program as the default program and will start by default each time the system starts.

Third approach: Power Shell Command deployment

First, the program is packaged, and the method is packaged with the second method.

WIN10 IoT supports FTP by default, using an FTP client to upload the program directory you just generated to the root of the Win10 IoT.

Start PowerShell with administrator privileges, enter the following command to connect to the Win10 IoT and enter the directory.

net start WinRM
Set-item Wsman:\localhost\client\trustedhosts-value 192.168.1.2
Enter-pssession-computername 192.168.1.2-credential 192.168.1.2\administrator

Locate the folder you just uploaded, use the cd command to go to the folder, locate the. appx file using the Add-appxpackage command, and here we perform the Add-appxpackage cloudtechiot1dot5_1.0.2.0_arm.appx.

The program starts to finish displaying the expected interface on the display.

The process of creating the Win10 IoT UI program here and deploying it in three ways is complete, and if the code has recommendations for optimization, please leave a message or email me ([email protected]). You can also scan the following QR code plus my number to view the previous article.

Project Source GitHub Https://github.com/CloudTechx/CloudTechIot under the Cloudtechiot1dot5 directory.

WIN10 IoT C # development 2-gpio Pin Control Light Emitting diode http://www.cnblogs.com/cloudtech/p/5617902.html

WIN10 IoT C # Development 1.5-three deployment methods for creating XAML-based UI programs and applications

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.