UWP入门(一) -- 先写几个简单控件简单熟悉下(别看这个)

原文:UWP入门(一) -- 先写几个简单控件简单熟悉下(别看这个)

1. MainPage.xmal

<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
        <Pivot x:Name="rootPivot" Title="Pivot Title">
            <PivotItem Header="Pivot Item 1">
                <!--Pivot content goes here-->
                <TextBlock Text="Content of pivot item 1."/>
            </PivotItem>
            <PivotItem Header="Pivot Item 2">
                <!--Pivot content goes here-->
                <TextBlock Text="Content of pivot item 2."/>
            </PivotItem>
            <PivotItem Header="Pivot Item 3">
                <!--Pivot content goes here-->
                <TextBlock Text="Content of pivot item 3."/>
            </PivotItem>
        </Pivot>
        <StackPanel VerticalAlignment="Bottom" HorizontalAlignment="Center">
            <ListView x:Name="listView1">
                <x:String>Item 1</x:String>
                <x:String>Item 2</x:String>
                <x:String>Item 3</x:String>
                <x:String>Item 4</x:String>
                <x:String>Item 5</x:String>
            </ListView>
            <Button Content="Submit" Click="SubmitButton_Click"/>
            <Button x:Name="btnMyClick" Click="Button_Click_1" Content="MessageDialog"/>
            <Button x:Name="btnMyClick2" Click="Button_Click_2" Content="ContentDialog"/>
            <TextBlock x:Name="response"  FontSize="36"/>
            <TextBlock x:Name="ticker" FontSize="36"/>
        </StackPanel>
        <Button x:Name="button" Content="Media" HorizontalAlignment="Left" Margin="149,177,0,0" VerticalAlignment="Top" Height="45" Width="69" Click="button_Click"/>
    </Grid>
</Page>

1.1 导航栏 (就是 标签栏)

     <Pivot x:Name="rootPivot" Title="Pivot Title">
            <PivotItem Header="Pivot Item 1">
                <!--Pivot content goes here-->
                <TextBlock Text="Content of pivot item 1."/>
            </PivotItem>
            <PivotItem Header="Pivot Item 2">
                <!--Pivot content goes here-->
                <TextBlock Text="Content of pivot item 2."/>
            </PivotItem>
            <PivotItem Header="Pivot Item 3">
                <!--Pivot content goes here-->
                <TextBlock Text="Content of pivot item 3."/>
            </PivotItem>
        </Pivot>

1.2 listview

            <ListView x:Name="listView1">
                <x:String>Item 1</x:String>
                <x:String>Item 2</x:String>
                <x:String>Item 3</x:String>
                <x:String>Item 4</x:String>
                <x:String>Item 5</x:String>
            </ListView>

1.3 Button

     <StackPanel VerticalAlignment="Bottom" HorizontalAlignment="Center">
            <Button Content="Submit" Click="SubmitButton_Click"/>
            <Button x:Name="btnMyClick" Click="Button_Click_1" Content="MessageDialog"/>
            <Button x:Name="btnMyClick2" Click="Button_Click_2" Content="ContentDialog"/>
        </StackPanel>

按 F12 生成点击事件代码,(async 异步)

  private async void Button_Click_1(object sender, RoutedEventArgs e)
        {
            await new Windows.UI.Popups.MessageDialog("Hello World").ShowAsync();
        }

        private async void Button_Click_2(object sender, RoutedEventArgs e)
        {
            var dialog = new ContentDialog()
            {
                Title = "提示",
                Content = "你确认要退出该页面吗?",
                PrimaryButtonText = "确定",
                SecondaryButtonText = "取消",
                FullSizeDesired = false,
            };

            await dialog.ShowAsync();
        }

        private async void button_Click(object sender, RoutedEventArgs e)
        {
                MediaElement mediaElement = new MediaElement();
                var synth = new Windows.Media.SpeechSynthesis.SpeechSynthesizer();
                Windows.Media.SpeechSynthesis.SpeechSynthesisStream stream = await synth.SynthesizeTextToStreamAsync("I Love U");
                mediaElement.SetSource(stream, stream.ContentType);
                mediaElement.Play();
        }

        private async void SubmitButton_Click(object sender, RoutedEventArgs e)
        {
            // Call app specific code to submit form. For example:
            // form.Submit();
            Windows.UI.Popups.MessageDialog messageDialog =
                new Windows.UI.Popups.MessageDialog("Thank you for your submission.");
            await messageDialog.ShowAsync();

        }
时间: 2024-08-17 14:08:52

UWP入门(一) -- 先写几个简单控件简单熟悉下(别看这个)的相关文章

ASP.NET AJAX入门系列(6):UpdateProgress控件简单介绍

在ASP.NET AJAX Beta2中,UpdateProgress控件已经从"增值"CTP中移到了ASP.NET AJAX核心中.以下两篇关于UpdateProgress的文章基本翻译自ASP.NET AJAX官方网站. 一.UpdateProgress控件简单使用 1.创建一个Web页面并切换到设计视图. 2.在工具箱的AJAX Extensions标签下,双击ScriptManager控件添加到页面中. 3.双击UpdatePanel控件添加到页面中. 4.双击UpdatePr

ASP.NET AJAX入门系列(10):Timer控件简单使用

本文主要通过一个简单示例,让Web页面在一定的时间间隔内局部刷新,来学习一下ASP.NET AJAX中的服务端Timer控件的简单使用. 1.添加新页面并切换到设计视图. 2.如果页面没有包含ScriptManager控件,在工具箱的AJAX Extensions标签下双击ScriptManager控件添加到页面中. 3.单击ScriptManager控件并双击UpdatePanel控件添加到页面中. 4.在UpdatePanel控件内单击并双击Timer控件添加到UpdatePanel中.Ti

自己动手写的jquery分页控件(非常简单实用)_jquery

最近接了一个项目,其中有需求要用到jquery分页控件,上网也找到了需要分页控件,各种写法各种用法,都是很复杂,最终决定自己动手写一个jquery分页控件,全当是练练手了.写的不好,还请见谅,本分页控件在chrome测试过,其他的兼容性不知道怎么没时间测试呢.欢迎有同样需求的小伙伴采用,在使用过程发现有问题欢迎提出批评建议.   css: @charset "utf-"; * { margin:px; padding:px; font-family:"微软雅黑";

Android RadioGroup和RadioButton控件简单用法示例

本文实例讲述了Android RadioGroup和RadioButton控件简单用法.分享给大家供大家参考,具体如下: RadioGroup和RadioButton代表的是Android中单选按钮的一种控件,写个简单的代码熟悉一下: import android.app.Activity; import android.os.Bundle; import android.widget.RadioButton; import android.widget.RadioGroup; import a

ASP.NET Atlas简单控件介绍

asp.net|控件 A  SP.NET Atlas中引入了客户端控件的概念,用面向对象思想将客户端JavaScript将要操作的DOM元素封装起来,带来了更清晰的代码模型以及更好的可复用性(不足之处是效率有所降低).Atlas的客户端控件是连接JavaScript与DOM元素的桥梁,我们应该尽可能的使用客户端控件与DOM元素打交道,也就是以Atlas的方法来编写我们的程序.同时,Atlas对JavaScript面向对象方面的强大扩展(请参考:ASP.NET Atlas对JavaScript的扩

MFC写的一个视频显示控件类,无法复用显示两路视频

问题描述 MFC写的一个视频显示控件类,无法复用显示两路视频 刚学MFC,仿照实例写了一个视频显示的控件类,SubDlgView ,这个类UI界面只有一个picture control,接口就是一个IP地址,在CAMDlg.h 里面定义两个私有成员SubDlgView videoDisplay2; SubDlgView videoDisplay; 但是显示的时候总是只能再第二个显示的控件中显示视频?不知道为什么 解决方案 控件只支持一个视频显示吧 做两个进程呢 解决方案二: 一个简单的验证方法,

ASP.NET Atlas简单控件介绍之四大控件

asp.net|控件 Atlas中的客户端控件均继承或间接继承于Sys.UI.Control基类(请参考:ASP.NET Atlas简单控件介绍之两个基类),并有所扩展,本文将介绍Atlas内建的简单控件InputControl,TextBox,Button和CheckBox. Sys.UI.InputControl InputControl类是一个抽象类,作为所有提供用户输入的控件(例如TextBox,见下文)的基类,提供了输入数据验证等公有操作.InputControl抽象类提供如下属性:

仿listBox写了一个Control控件为item的列表集合

  仿listBox写了一个Control控件为item的列表集合,由于最近做个项目要用,微软提供的控件实现起来不行,但自己写了一个,效果如下: 代码   1using System;  2using System.Collections.Generic;  3using System.ComponentModel;  4using System.Data;  5using System.Drawing;  6using System.Text;  7using System.Text.Regu

listview-急!android我自己写了个组合控件RelativeLayout,怎么加入ListView

问题描述 急!android我自己写了个组合控件RelativeLayout,怎么加入ListView public class Viewg extends RelativeLayout { private TextView number; private EditText thing; private Button biaozhu; private Button delete; private int isbiaozhu=0; private int xiabiao; public Viewg