页面之间跳转(传值)


            string txt = "Spring Lee";
this.Frame.Navigate(typeof(BlankPage1),txt);

另一个页面接收

protected override void OnNavigatedTo(NavigationEventArgs e)
{
if (e.Parameter!=null)
{
T.Content = e.Parameter.ToString();
}
}

Toast通知


private void Button_Click(object sender, RoutedEventArgs e)
{
var toast = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText01); var textNodes = toast.GetElementsByTagName("text"); textNodes[].InnerText = "呵呵呵"; var Message = new ToastNotification(toast); ToastNotificationManager.CreateToastNotifier().Show(Message); }

磁贴操作


添加磁贴

private async void Button_Click(object sender, RoutedEventArgs e)
{
//磁贴的唯一标识
string TitleId = "My_Title"; //磁贴展示名称
string DiaplayName = "我的磁贴"; //点击磁贴传入的参数
string args = DateTime.Now.ToString(); //磁贴图片URI
Uri LogoUri = new Uri("ms-appx:///Assets/cc.jpg"); //磁贴尺寸
var size = TileSize.Square150x150; var Obj = new SecondaryTile(TitleId,DiaplayName,args,LogoUri,size); Obj.VisualElements.ShowNameOnSquare150x150Logo = true; if (await Obj.RequestCreateAsync())
{
await new MessageDialog("OK").ShowAsync();
} }
  

删除,修改磁贴

 private async void Button_Click_1(object sender, RoutedEventArgs e)
{
//磁贴的唯一标识
string TitleId = "My_Title";
var Title = new SecondaryTile(TitleId); Title.VisualElements.ShowNameOnSquare150x150Logo = false;
await Title.RequestDeleteAsync(); }

 

磁贴通知


            var toast = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText01);

            var textNodes = toast.GetElementsByTagName("text");

            textNodes[].InnerText = "呵呵呵";
textNodes[].InnerText = "你是猴子请来的救兵吗?";
textNodes[].InnerText = "呵呵呵"; var Message = new TileNotification(toast);
TileUpdateManager.CreateTileUpdaterForSecondaryTile("My_Title").Update(Message);
  

HttpClient


            string url = "http://www.baidu.com";
HttpClient client = new HttpClient();
string responce = await client.GetStringAsync(url);

Weather天气实战


利用GPS获取手机坐标(经纬度)

            var geo = new Geolocator();
var P = await geo.GetGeopositionAsync();
var Po = P.Coordinate.Point.Position;

百度地图API获取位置信息

            string AppId = "XTTNdkZYIFCIqKVW1vfYUID3eWOgizwC";
string Type = "json"; string Url = "http://api.map.baidu.com/geocoder/v2/?ak=" + AppId + "&location=" + Po.Latitude + "," + Po.Longitude + "&output=" + Type + ""; HttpClient client = new HttpClient();
var json = await client.GetStringAsync(Url); JsonObject jsonRes = JsonObject.Parse(json);
var City = jsonRes.GetNamedObject("result").GetNamedObject("addressComponent").GetNamedString("city");

百度天气接口 获取天气信息

            string WeaApi = "http://api.map.baidu.com/telematics/v3/weather?location=" + City + "&output=json&ak=" + AppId;

            var WeatherJson = await client.GetStringAsync(WeaApi);
Info i= JsonConvert.DeserializeObject<Info>(WeatherJson);
this.DataContext = i;

天气信息 Info Class

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks; namespace Weather
{
public class Info
{
public int error { get; set; }
public string status { get; set; }
public string date { get; set; }
public List<result> results { get; set; } } public class result
{
public string currentCity { get; set; }
public string pm25 { get; set; } public IList<indexitem> index { get; set; }
public IList<weather_data_item> weather_data { get; set; }
} public struct weather_data_item
{
public string date { get; set; }
public string dayPictureUrl { get; set; }
public string nightPictureUrl { get; set; }
public string weather { get; set; }
public string wind { get; set; }
public string temperature { get; set; } } public struct indexitem
{ public string title { get; set; }
public string zs { get; set; }
public string tipt { get; set; }
public string des { get; set; }
}
}

前台Xmal代码绑定

<Page
x:Class="Weather.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Weather"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> <Grid>
<Grid.Background>
<ImageBrush ImageSource="ms-appx:///Assets/zhuo.jpeg"/>
</Grid.Background>
<ProgressRing x:Name="gif"></ProgressRing>
<Hub Header="Weather">
<HubSection>
<DataTemplate>
<StackPanel>
<TextBlock Text="{Binding results[0].currentCity}" FontSize=""></TextBlock>
<TextBlock Text="{Binding results[0].pm25}" FontSize=""></TextBlock>
</StackPanel>
</DataTemplate>
</HubSection>
<HubSection>
<DataTemplate>
<ListView ItemsSource="{Binding results[0].weather_data}">
<ListView.ItemTemplate>
<DataTemplate> <Border Width="" BorderThickness="" BorderBrush="Green">
<StackPanel>
<TextBlock Text="{Binding date}" FontSize=""></TextBlock>
<TextBlock Text="{Binding weather}" FontSize=""></TextBlock>
<StackPanel Orientation="Horizontal">
<Image Source="{Binding dayPictureUrl}" Stretch="Uniform" Width="" Height=""></Image>
</StackPanel>
<TextBlock Text="{Binding wind}" FontSize=""></TextBlock>
<TextBlock Text="{Binding temperature}" FontSize=""></TextBlock> </StackPanel>
</Border> </DataTemplate>
</ListView.ItemTemplate>
</ListView>
</DataTemplate>
</HubSection>
<HubSection>
<DataTemplate>
<ListView ItemsSource="{Binding results[0].index}">
<ListView.ItemTemplate>
<DataTemplate>
<Border>
<StackPanel>
<TextBlock Text="{Binding tipt}" FontSize="" Foreground="#FF2996AE"></TextBlock>
<TextBlock Text="{Binding zs}" FontSize="" Foreground="Green"></TextBlock>
<TextBlock Text="{Binding des}" FontSize="" TextWrapping="Wrap"></TextBlock>
</StackPanel>
</Border>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</DataTemplate>
</HubSection>
</Hub>
</Grid>
</Page>

天气数据加载时用ProgressRing控制

 <ProgressRing x:Name="Pro"></ProgressRing>

加载前

Pro.IsActive=True;

加载完毕

Pro.IsActive=false;

数据绑定 


 public  class User
{
public string Name { get; set; }
public string Phone { get; set; }
public string Address { get; set; }
} protected override void OnNavigatedTo(NavigationEventArgs e)
{
// TODO: 准备此处显示的页面。 // TODO: 如果您的应用程序包含多个页面,请确保
// 通过注册以下事件来处理硬件“后退”按钮:
// Windows.Phone.UI.Input.HardwareButtons.BackPressed 事件。
// 如果使用由某些模板提供的 NavigationHelper,
// 则系统会为您处理该事件。 User U = new User();
U.Name = "张三";
U.Phone = "";
U.Address = "东北";
this.DataContext = U;
}
       <TextBox Text="{Binding }"></TextBox>
<TextBox Text="{Binding Name}"></TextBox>
<TextBox Text="{Binding Address}"></TextBox>

UWP汉堡包菜单 


Xaml: 
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> <AppBarButton Click="Button_Click" Height="" Width="">
<SymbolIcon Symbol="Bold" HorizontalAlignment="Left" VerticalAlignment="Top"/>
</AppBarButton> <SplitView x:Name="mySplit" DisplayMode="CompactOverlay" CompactPaneLength=""
OpenPaneLength="" IsPaneOpen="False" > <SplitView.Pane>
<StackPanel Background="Pink">
<AppBarButton Click="Button_Click" Height="" Width="">
<SymbolIcon Symbol="Bold" HorizontalAlignment="Left" VerticalAlignment="Top"/>
</AppBarButton>
<TextBlock FontSize="">第一项</TextBlock>
<TextBlock FontSize="">第二项</TextBlock>
<TextBlock FontSize="">第一项</TextBlock>
<TextBlock FontSize="">第二项</TextBlock>
<TextBlock FontSize="">第一项</TextBlock>
<TextBlock FontSize="">第二项</TextBlock>
</StackPanel>
</SplitView.Pane>
<TextBlock HorizontalAlignment="Center"
VerticalAlignment="Center" FontSize="">Spring</TextBlock>
</SplitView>
</Grid> CS:

private void Button_Click(object sender, RoutedEventArgs e)
{
  mySplit.IsPaneOpen = !mySplit.IsPaneOpen;
}


Win10 UWP 开发学习代码(不断更新)的更多相关文章

  1. Win10 UWP开发系列:使用VS2015 Update2+ionic开发第一个Cordova App

    安装VS2015 Update2的过程是非常曲折的.还好经过不懈的努力,终于折腾成功了. 如果开发Cordova项目的话,推荐大家用一下ionic这个框架,效果还不错.对于Cordova.PhoneG ...

  2. Win10/UWP开发—使用Cortana语音与App后台Service交互

    上篇文章中我们介绍了使用Cortana调用前台App,不熟悉的移步到:Win10/UWP开发—使用Cortana语音指令与App的前台交互,这篇我们讲讲如何使用Cortana调用App的后台任务,相比 ...

  3. Win10/UWP开发—凭据保险箱PasswordVault

    PasswordVault用户凭据保险箱其实并不算是Win10的新功能,早在Windows 8.0时代就已经存在了,本文仅仅是介绍在UWP应用中如何使用凭据保险箱进行安全存储和检索用户凭据. 那么什么 ...

  4. Win10/UWP开发—使用Cortana语音指令与App的前台交互

    Win10开发中最具有系统特色的功能点绝对少不了集成Cortana语音指令,其实Cortana语音指令在以前的wp8/8.1时就已经存在了,发展到了Win10,Cortana最明显的进步就是开始支持调 ...

  5. Win10 UWP开发系列:实现Master/Detail布局

    在开发XX新闻的过程中,UI部分使用了Master/Detail(大纲/细节)布局样式.Win10系统中的邮件App就是这种样式,左侧一个列表,右侧是详情页面.关于这种 样式的说明可参看MSDN文档: ...

  6. Win10 UWP 开发系列:使用SQLite

    在App开发过程中,肯定需要有一些数据要存储在本地,简单的配置可以序列化后存成文件,比如LocalSettings的方式,或保存在独立存储中.但如果数据多的话,还是需要本地数据库的支持.在UWP开发中 ...

  7. Win10 UWP开发实现Bing翻译

    微软在WP上的发展从原来的Win7到Win8,Win8.1,到现在的Win10 UWP,什么是UWP,UWP即Windows 10 中的Universal Windows Platform简称.即Wi ...

  8. Win10/UWP开发-Ink墨迹书写

    在UWP开发中,微软提供了一个新型的InkCanvas控件用来让用户能书写墨迹,在新版的Edga浏览器中微软自己也用到了该控件使用户很方便的可以在web上做笔记. InkCanvas控件使用很简单,从 ...

  9. Win10 UWP开发中的重复性静态UI绘制小技巧 2

    小技巧1 地址:http://www.cnblogs.com/ms-uap/p/4641419.html 介绍 我们在上一篇博文中展示了通过Shape.Stroke族属性实现静态重复性UI绘制,使得U ...

随机推荐

  1. PHP

    * PHP语言1.基本内容 * PHP语言 - 类似于javascript语言的 * javascript是客户端(HTML)的脚本语言 * PHP是服务器端的脚本语言 * PHP文件的扩展名为&qu ...

  2. jQuery构造函数分析

    在我的上一篇文章里面 阐述了jQuery的大致框架,知道了所有代码都是写在了一个自调用匿名函数里面,并且传入了window对象,源码是这样的: (function( window, undefined ...

  3. JavaScript小细节点罗列

    共勉! 属性访问表达式 众所周知,JavaScript为属性的访问定义了两种语法方式: 表达式.标识符 // 表达式(指定对象) 标识符(指定需要访问的属性的名称) 表达式[表达式] //表达式1(指 ...

  4. C#通过WMI的wind32 的API函数实现msinfo32的本地和远程计算机的系统日志查看功能

    先不说如何实现,先来看看效果图: 读取远程的需要提供下远程的计算用户名和密码即可. 如何实现这个代码功能,请看如下代码部分: 实体类: using System; using System.Colle ...

  5. iOS开发之功能模块--长方形UIImage截取中间最大正方形区域

    这里直接用CoreGraphics的一些处理图片的方法,本身不难,但是有些时候用的不多,就会遗忘掉使用方法的细节.下面就直接展示关键源码,以便下次重复需求,就可以立马找回. 该方法中在UIImage的 ...

  6. AEAI Portal V3.5.4升级说明,门户集成平台

    1 总体说明 本次升级是AEAI Portal的一次重要升级,主要扩展了开发社区(论坛).移动门户功能,同时修正一些功能BUG等,具体内容如下: 2 升级内容 功能扩展: 扩展开发社区导航 扩展移动门 ...

  7. Xamarin For Visual Studio 3.0.54.0 完整离线破解版(C# 开发Android、IOS工具 吾乐吧软件站分享)

    Xamarin For Visual Studio就是原本的Xamarin For Android 以及 Xamarin For iOS,最新版的已经把两个独立的插件合并为一个exe安装包了.为了区分 ...

  8. SQL SERVER错误:已超过了锁请求超时时段。 (Microsoft SQL Server,错误: 1222)

    在SSMS(Microsoft SQL Server Management Studio)里面,查看数据库对应的表的时候,会遇到"Lock Request time out period e ...

  9. 初刷LeetCode的感受

    自从上个月进入实验室的云安全项目组后,因为要接触到实际的代码,在实验室博士的建议下我们项目组的硕士开始刷LeetCode练习编程能力,保持每周抽空刷几道算法题.虽然刷的不多,到现在一共只刷了不到30题 ...

  10. mysql编码格式设置

    两个地方能影响到mysql的编码格式 ①.[mysql]下default-character-set=GBK//指的是客户端输入的内容的编码(GBK只是支持中英文)②.[mysqld]下# The d ...