Win8应用开发 入门篇(一) Hello world!
来源:互联网 发布:查看端口占用linux 编辑:程序博客网 时间:2024/06/06 17:57
启动VS2012—>新建项—>选择windows应用商店模版,
1.空白应用程序,可以从右侧看到相关图文介绍
2.拆分布局应用程序
3.网格应用程序
创建项目时,会提示获取开发者许可证,用微软账户登录即可获取开发者许可证。
然后项目创建成功,我们打开MainPage.xaml将会加载设计器,可以进行控件拖拽。
1.可以从工具箱中拖入控件到视图中,当然也可以直接在xaml中编写代码。首先我们拖一个按钮上去,可以在属性栏中给按钮的文设定文字,也可以直接在xaml中添加Content属性。
2.然后再拖入一个TextBox控件,双击可修改文本中内容,拖动可以设定布局位置,给这个TextBox添加一个x:Name属性,就叫tb吧并把它的可见性设为不可见。
3.然后双击按钮进入按钮的单击事件,在后台代码中应用tb这个控件。我们设定点击这个按钮,把文本框显示出来,并显示hello world。
MainPage.xaml代码如下
<Page x:Class="App1.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:App1" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d"> <Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}"> <Button Content="点击" Padding="10" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="61,85,1172,615" Width="133" FontSize="22" Height="68" Click="Button_Click_1" RenderTransformOrigin="-0.203,0.543" /> <TextBox x:Name="tb" HorizontalAlignment="Center" Margin="61,455,765,0" TextWrapping="Wrap" VerticalAlignment="Top" RenderTransformOrigin="0.55,0.572" Width="540" Height="102" FontSize="24" Visibility="Collapsed"/> </Grid></Page>
MainPage.xaml.cs代码如下:
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;// “空白页”项模板在 http://go.microsoft.com/fwlink/?LinkId=234238 上有介绍namespace App1{ /// <summary> /// 可用于自身或导航至 Frame 内部的空白页。 /// </summary> public sealed partial class MainPage : Page { public MainPage() { this.InitializeComponent(); } /// <summary> /// 在此页将要在 Frame 中显示时进行调用。 /// </summary> /// <param name="e">描述如何访问此页的事件数据。Parameter /// 属性通常用于配置页。</param> protected override void OnNavigatedTo(NavigationEventArgs e) { } private void Button_Click_1(object sender, RoutedEventArgs e) { tb.Visibility = Windows.UI.Xaml.Visibility.Visible; tb.Text = "Hello Bvin's World!!"; } }}
启动,看见就一个按钮。
点击这个按钮,就把TextBox给显示出来了。
- Win8应用开发 入门篇(一) Hello world!
- SpringBoot开发入门(一)Hello World
- Spring Boot学习入门篇(一)--Hello World
- (一)nodejs入门之 'Hello World'
- SpringBoot入门(一)之Hello World
- Eclipse插件开发(一)Hello World
- Python Embedding 开发 - Hello World (一)
- iPhone 开发(一) Hello World 初试
- iPhone 开发(一) Hello World 开始
- Android开发历程(一) hello world
- NDK开发 (一)Hello World!
- Python入门 (一) hello world
- SpringMVC入门一(hello world)
- SpringBoot入门:Hello World(一)
- 安卓开发入门(一):环境搭建,“Hello, World”
- Android开发入门Hello World
- Android开发入门:Hello,World!
- Android开发入门Hello World
- Javaの线程之多线程执行顺序
- 【OpenCV学习笔记】第一篇 搭建环境
- ChecksumException: Checksum error
- 【ios6.0 自学瞎折腾】(一) Helloworld!
- [windows phone自学笔记] 第一篇 HelloWorld!
- Win8应用开发 入门篇(一) Hello world!
- [windows phone自学笔记] 第二篇 Button控件
- Win8应用开发 入门篇(二)富文本和消息框
- 【ios6.0 自学瞎折腾】(二)控件交互和对话框
- 【ios6.0 自学瞎折腾】(三)表示图填充数据
- WebService(一)Hello world!和IIS配置
- AndroidのBitmap之大图片优化
- AndroidのIntent之传递List
- AndroidのActivity之退出返回栈(二)