页面之间跳转(传值)


            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. [deviceone开发]-多种样式下拉菜单demo

    一.简介 该demo主要展示了3种下拉菜单. 一.仿QQ弹出菜单 主要实现原理是通过add一个ui,然后通过点击事件控制其visible属性来显示或者隐藏. 二.组合下拉菜单 主要用到的控件是do_A ...

  2. Oracle常用SQL查询

    一.ORACLE的启动和关闭 1.在单机环境下要想启动或关闭oracle系统必须首先切换到oracle用户,如下: su - oracle a.启动Oracle系统 oracle>svrmgrl ...

  3. Android app被系统kill的场景

    何时发生 当我们的app被切到后台的时候,比如用户按下了home键或者切换到了别的应用,总之是我们的app不再和用户交互了,这个时候对于我们的app来说就是什么事情都可能发生的时候了,因为系统会认为你 ...

  4. Play Framework 完整实现一个APP(九)

    添加增删改查操作 1.开启CRUD Module 在/conf/application.conf 中添加 # Import the crud module module.crud=${play.pat ...

  5. Microsoft IoT Starter Kit 开发初体验

    1. 引子 今年6月底,在上海举办的中国国际物联网大会上,微软中国面向中国物联网社区推出了Microsoft IoT Starter Kit ,并且免费开放1000套的申请.申请地址为:http:// ...

  6. jQuery中多个元素的Hover事件

    1.需求简介 jQuery的hover事件只是针对单个HTML元素,例如: $('#login').hover(fun2, fun2); 当鼠标进入#login元素时调用fun1函数,离开时则调用fu ...

  7. sshfs 实现普通用户可读写

    先实现普通用户免密码host1可登入host2host1# yum install fuse sshfs; 如果装不上,需要安装epep源 --enablerepo=epelhost1# su - e ...

  8. oracle数据库rman备份计划及恢复

    1.rman完全恢复的前提条件:历史的datafile,controlfile和spfile备份,加上完整的archivelog和完好的redolog. 2.rman备份脚本: a.RMAN 0级备份 ...

  9. eclipse中去除build时总是js错误的问题

    在用eclipse时经常莫名其名的弹出如下框框,有的时候甚至还死循环了.严重影响开发效率. 原因分析就是我们项目的一些js代码,eclipse验证时有错误的,其实是没有错误的.不知道eclipse是怎 ...

  10. jni调试3(线程调试env变量问题)

    jni层调试线程死机原因 一,导致死机原因:   jni层中  线程函数中  只要添加调用env 的函数 ,,就会死机     二,解决方法 第一我们应该理解: ①(独立性) JNIEnv 是一个与线 ...