• UWP简单测试


    随便写下,试试.Net Core与UWP开发,后台WCF

    XAML

    <Page
        x:Class="App3.MainPage"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="using:App3"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        mc:Ignorable="d">
    
        <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" >
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="100"></ColumnDefinition>
                <ColumnDefinition Width="*"></ColumnDefinition>
                <ColumnDefinition Width="*"></ColumnDefinition>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="100"></RowDefinition>
                <RowDefinition Height="*"></RowDefinition>
            </Grid.RowDefinitions>
            <Button Grid.Column="0" Grid.Row="0" Name="btnNew" Content="New" Click="btnNew_Click" ></Button>
            <TextBox x:Name="txtTime" Grid.Column="0" Grid.Row="1" TextWrapping="Wrap" Text="" VerticalAlignment="Stretch"  />
            <Button Grid.Column="1" Grid.Row="0" x:Name="btnNew_Copy" Content="New" Click="btnNew_Copy_Click" />
            <TextBox x:Name="txtText" Grid.Column="1" Grid.Row="1" TextWrapping="Wrap" Text="" VerticalAlignment="Stretch" Grid.ColumnSpan="2" />
        </Grid>
    </Page>

    CS页

    using System;
    using System.Collections.Generic;
    using System.IO;
    using System.Linq;
    using System.Runtime.InteropServices.WindowsRuntime;
    using System.Threading.Tasks;
    using Windows.Foundation;
    using Windows.Foundation.Collections;
    using Windows.UI.Popups;
    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;
    
    // The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409
    
    namespace App3
    {
        /// <summary>
        /// An empty page that can be used on its own or navigated to within a Frame.
        /// </summary>
        public sealed partial class MainPage : Page
        {
            protected int count = 0;
            public MainPage()
            {
                this.InitializeComponent();
                DispatcherTimer timer = new DispatcherTimer();
                timer.Interval = new TimeSpan(3000);
                timer.Tick += Timer_Tick;
                timer.Start();
            }
    
            private void btnNew_Click(object sender, RoutedEventArgs e)
            {
                var buttonLabel =  Dispatcher.RunAsync( Windows.UI.Core.CoreDispatcherPriority.Normal, async () =>
                {
                    var popup = new Windows.UI.Popups.MessageDialog("Question", "Please pick a button to continue");
                    popup.Commands.Add(new Windows.UI.Popups.UICommand("Button 1"));
                    popup.Commands.Add(new Windows.UI.Popups.UICommand("Button 2", new Windows.UI.Popups.UICommandInvokedHandler(commandShow)));
                    popup.CancelCommandIndex = 0;
                    
                    // About to show the dialog
                    var command = await popup.ShowAsync();
    
                    // Dialog has been dismissed by the user
                });
              
            }
    
            private void commandShow(IUICommand command)
            {
                txtText.Text = "22";
            }
    
            public static async Task<string> ShowMessageAsync()
            {
                // Set up a MessageDialog
                var popup = new Windows.UI.Popups.MessageDialog("Question", "Please pick a button to continue");
                popup.Commands.Add(new Windows.UI.Popups.UICommand("Button 1"));
                popup.Commands.Add(new Windows.UI.Popups.UICommand("Button 2"));
                popup.CancelCommandIndex = 0;
    
                // About to show the dialog
                var command = await popup.ShowAsync();
    
                // Dialog has been dismissed by the user
                return command.Label;
            }
    
            private void Timer_Tick(object sender, object e)
            {
                txtTime.Text = (count++).ToString();
            }
    
            private async void btnNew_Copy_Click(object sender, RoutedEventArgs e)
            {
                 txtText.Text = await WCFService.GetDataAsync(2);
            }
        }
    }

    发布可通过store发布windows store或发布测试版,需手工安装证书与对应版本CoreRuntime

  • 相关阅读:
    SDL 学习及相关API
    ppm图像格式
    Gstreamer学习
    GObject对象系统
    Linux下查看文件和文件夹大小
    将输入的字符串按指定的长度进行拆分
    Ubuntu12.04 下安装Chrome浏览器
    Ubuntu12.04 下搭建Java开发环境
    Android 之 WebView
    Ubuntu Desktop 16.04 LTS 下成功配置Jupyter的两个python内核版本(2.7x,3.5x)
  • 原文地址:https://www.cnblogs.com/leif/p/7804081.html
Copyright © 2020-2023  润新知