页面之间跳转(传值)
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[0].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[0].InnerText = "呵呵呵";
textNodes[1].InnerText = "你是猴子请来的救兵吗?";
textNodes[2].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= JsonConve