页面之间跳转(传值)


            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. CSS3中flexbox如何实现水平垂直居中和三列等高布局

    最近这些天都在弥补css以及css3的基础知识,在打开网页的时候,发现了火狐默认首页上有这样一个东西.

  2. css相对定位和绝对定位

    相对定位,是对原来元素的位置为参照物进行定位: 绝对定位,如果父级没有定位,则针对HTML为参照物进行定位:如果父级有定位,则针对父元素为参照物进行定位

  3. 从FineReport看开放式引擎API

    对于一款软件或产品,尤其是一些企业级应用的IT软件,是不可能满足所有需求的.尤其是针对业务化的产品需求,某些个性化的需求就要进行二次开发.二次开发需要API接口,无论是什么样的开发,开发人员都需要对开 ...

  4. docker'部署

    环境:ubuntu-14.04.4-server-amd64 1.更换阿里云源 备份源配置文件: $ sudo cp /etc/apt/sources.list /etc/apt/sources.li ...

  5. [AlwaysOn Availability Groups]AlwaysOn等待类型

    AlwaysOn等待类型 当排查AlwaysOn延迟,等待统计信息可以在DMV中查看累计的AlwaysOn等待类型. 查看AlwaysOn等待类型 SELECT * FROM sys.dm_os_wa ...

  6. [iOS]坑爹的ALAsset(Assets Library Framework)

    Assets Library Framework 可以用来做iOS上的多选器,选照片视频啥的啦就不介绍了. 目前的项目有点类似dropbox,可以选择设备内的照片然后帮你上传文件,使用了Assets ...

  7. Python urllib2 调试

    #!/usr/bin/env python # coding=utf-8 __author__ = 'zhaoyingnan' import urllib import urllib2 import ...

  8. gdb进程调试,多进程调试

    1.单进程的调试 常规的通过gdb cmd这种方式开启调试,特别说明的是通过attach的方法附加到一个指定的进程上去进行调试,这种方法适合于调试一个已经运行的进程,具体用法:  gdb -p [pi ...

  9. nginx 日志相关配置总结

    设置位于nginx.conf:         log_format  main  '$server_name $remote_addr - $remote_user [$time_local] &q ...

  10. [WPF系列]-使用Binding来同步不同控件的Dependency property

    简介 项目中经常会用到,同步两个控件的值,本文就简单列举两种方式来同步不同控件的两个Dependency Property. 示例 效果图: 只使用C#代码: //获取slider1的ValueDep ...