Experience Win8 Metro application development

Source: Internet
Author: User

Install Windows 8 Consumer Preview and Visual Studio 2011 Beta to develop a Metro-style application. First, write HelloWorld.

The Metro Style App supports multiple development methods, including:

☆Xaml/C # Or XAML/VB. Net
☆Html/JS
☆Xaml/C ++
☆Directx/C ++

You can also mix several technologies for development. I will try it with XAML/C # first.


1. Build a project

In the Win8 environment, Windows Metro style is displayed during project creation. This option is invisible in non-Win8 environments. Create a Blank Application, which is the simplest.

650) this. width = 650; "border =" 0 "alt =" "width =" 640 "height =" 480 "src =" http://www.bkjia.com/uploads/allimg/131228/1J551A55-0.png "/>


2. Write interface xamlblkpage. xaml)

Put only two textblocks to display text information.

 
 
  1. <Page
  2. X: Class = "HelloWorld. BlankPage"
  3. Xmlns = "http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  4. Xmlns: x = "http://schemas.microsoft.com/winfx/2006/xaml"
  5. Xmlns: local = "using: HelloWorld"
  6. Xmlns: d = "http://schemas.microsoft.com/expression/blend/2008"
  7. Xmlns: mc = "http://schemas.openxmlformats.org/markup-compatibility/2006"
  8. Mc: Ignorable = "d">
  9.  
  10. <Grid Background = "{StaticResource ApplicationPageBackgroundBrush}">
  11. <StackPanel>
  12. <! -- Put two textblocks on the interface, one displaying Hello World and the other displaying time -->
  13. <TextBlock FontSize = "60" HorizontalAlignment = "Center" Margin = "0,200,"> Hello World! </TextBlock>
  14. <TextBlock Name = "txtCurrentTime" FontSize = "48" HorizontalAlignment = "Center" Margin = ","> </TextBlock>
  15. </StackPanel>
  16. </Grid>
  17. </Page>


3. Write the code "BlankPage. xaml. cs)

Write several lines of code in the OnNavigatedTo method to display the current time in the second TextBlock on the interface.

 
 
  1. Protected override void OnNavigatedTo (NavigationEventArgs e)
  2. {
  3. // Create a timer. Update the Text of txtCurrentTime every second to the current time.
  4. Var timer = new DispatcherTimer ();
  5. Timer. Interval = TimeSpan. FromSeconds (1 );
  6. Timer. Tick + = (sender, args) => {
  7. TxtCurrentTime. Text = DateTime. Now. ToString ();
  8. };
  9. Timer. Start ();
  10. }

OK. Run Ctrl + F5. The effect is as follows:

650) this. width = 650; "border =" 0 "alt =" "width =" 320 "height =" 240 "style =" border: 1px solid # ccc "src =" http://www.bkjia.com/uploads/allimg/131228/1J551C41-1.png "/>

PS: To develop a Metro application on Win8, you must register a developer license first.

 

This article from the rabbit nest blog, please be sure to keep this source http://boytnt.blog.51cto.com/966121/859804

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.