页面之间跳转(传值)


            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. 关于checkbox的全选和反选实例

    <script type="text/javascript"> $(function () { $("#checkAll").click(funct ...

  2. WWDC 后苹果最新 App Store 审核条款!

        WWDC 2016 大会之后,苹果公司发布了四个全新平台:iOS,macOS,watchOS 和 tvOS.并且在此之后,苹果应用商店审核条款也同时进行了更新——貌似不算进行了更新,简直就是重 ...

  3. Android应用开发基础之十二:版本控制

    为什么需要版本控制? 场景1: 你的代码正常工作 你改了其中的几行代码 程序出了问题 你把代码改回来 程序还是不能正常工作——为什么? 场景2: 你的程序昨天还能正常运行 昨天晚上你修改了很多内容,做 ...

  4. sql 截取日期

    截取日期: select to_char( NEW_TIME( sysdate, 'GMT','EST'), 'yyyy-mm')from dual; 或得年或月或日   Year/ month/Da ...

  5. [AlwaysOn Availability Groups]DMV和系统目录视图

    DMV和系统目录视图 这里主要介绍AlwaysON的动态管理视图,可以用来监控和排查你的AG. 在AlwaysOn Dashboard,你可以简单的配置的GUI显示很多可用副本的DMV和可用数据库通过 ...

  6. .NET重构—单元测试的代码重构

    阅读目录: 1.开篇介绍 2.单元测试.测试用例代码重复问题(大量使用重复的Mock对象及测试数据) 2.1.单元测试的继承体系(利用超类来减少Mock对象的使用) 2.1.1.公用的MOCK对象: ...

  7. 【转】hive导入数据出现NULL

    在把hdfs上数据迁移到hive中的表时,若出现数据位NULL,是因为没有指定列分隔符. 由于hive默认的分隔符是/u0001(Ctrl+A),为了平滑迁移,需要在创建表格时指定数据的分割符号,语法 ...

  8. Spring IOC/DI和AOP原理

    一 IOC/DI 1. 概念机原理 IOC: Inversion of Control(控制反转)是一种设计思想,就是容器控制应用程序所需要外部资源的创建和管理,然后将其反转给应用程序.对象及其依赖对 ...

  9. 问题解决——CVSListBox的使用

    =================================版权声明================================= 版权声明:本文为博主原创文章 未经许可不得转载  请通过右 ...

  10. openstack api快速入门

    原文:http://my.oschina.net/guol/blog/105430 openstack官方有提供api供开发者使用,可以使用api做一些外围的小工具,用来简化对openstack的管理 ...