Tag:win8 live tile
Using demo02.common;using system;using system.collections.generic;using system.io;using System.Linq;using System.runtime.interopservices.windowsruntime;using windows.applicationmodel;using Windows.applicationmodel.activation;using windows.foundation;using windows.foundation.collections;using Windows.ui.xaml;using windows.ui.xaml.controls;using windows.ui.xaml.controls.primitives;using Windows.ui.xaml.data;using windows.ui.xaml.input;using windows.ui.xaml.media;using Windows.UI.Xaml.Navigation; Using windows.ui.applicationsettings;using system.threading.tasks;using windows.ui.notifications;using demo02. Datastructure;using windows.data.xml.dom;using windows.storage.streams;using windows.storage;using Windows.networking.backgroundtransfer;using windows.storage.pickers;using newtonsoft.json;using System.collections.objectmodel;using demo02. Helper;using wherewego.helper;using system.net.http;using system.net;using Windows.Networking.PushNotifications; Using microsoft.windowsazure.messaging;//"Hub Application" template in http://go.microsoft.com/fwlink/? LINKID=321221 has introduced namespace demo02{sealed partial class App:application {public App () { This. InitializeComponent (); This. Suspending + = onsuspending; } protected override async void OnLaunched (Launchactivatedeventargs e) {#if DEBUG if (system.diag Nostics. debugger.isattached) {this. Debugsettings.enableframeratecounter = true; } #endif Frame rootframe = Window.Current.Content as Frame; if (Rootframe = = null) {rootframe = new Frame (); Suspensionmanager.registerframe (Rootframe, "appframe"); Rootframe.language = Windows.globalization.applicationlanguages.languages[0]; rootframe.navigationfailed + = onnavigationfailed; if (e.previousexecutionstate = = applicationexecutionstate.terminated) {Try {await suspensionmanager.restoreasync (); } catch (Suspensionmanagerexception) {}} Settingspane.getforcurrentview (). commandsrequested + = oncommandsrequested; Window.Current.Content = Rootframe; } if (rootframe.content = = null) {rootframe.navigate (typeof (Hubpage), e.ar guments); } await configurenotifications (); Live tile call Window.Current.Activate (); } private Async static Task configurenotifications () {//Send local notifications//t Ileupdatemanager.createtileupdaterforapplication (). Enablenotificationqueueforsquare310x310 (TRUE); var toprated = await demo02. DataModel.WWGDataSource.GetTileUAsync (); Get the data source for the live tile foreach (var recipe in toprated.universities)//toprated.univErsities is a observablecollection<offlinepicuri> {var templatecontent = tileupdatemanager.ge Ttemplatecontent (tiletemplatetype.tilesquare310x310blockandtext02); Set templates for Live tiles//bind pictures to live tiles//Attach Special Note: The picture cannot be too large, otherwise it cannot display var imageattributes = Templatecontent.getelementsbytagname (" Image "); ((XmlElement) imageattributes[0]). SetAttribute ("src", "ms-appx:///" + recipe. Tileimagepath); System.Diagnostics.Debug.WriteLine (recipe. Tileimagepath); ((XmlElement) imageattributes[0]). SetAttribute ("alt", recipe. Name);//Add text to the live tile var tiletextattributes = templatecontent.getelementsbytagname ("text"); TILETEXTATTRIBUTES[1]. InnerText = recipe. Name; TILETEXTATTRIBUTES[3]. InnerText = "Brief Info"; TILETEXTATTRIBUTES[4]. InnerText = recipe. Summary; TILETEXTATTRIBUTES[5]. InnerText = recipe. Summary; TILETEXTATTRIBUTES[6]. InnerText = recipe. StaRS + "stars";//here to pay special attention: to make each ID is different, otherwise it will not show var tilenotification = new Tilenotification (TemplateContent); Tilenotification.tag = recipe. Id; Tileupdatemanager.createtileupdaterforapplication (). Update (tilenotification); }}}}/*********************************************************************************///attached: Top TOPR Ated. Universities the class of element University in the collection/********************************************************************************* /using demo02. Helper;using system;using system.collections.generic;using system.collections.objectmodel;using System.Linq;using System.text;using system.threading.tasks;namespace demo02. datamodel{public class University:base {public University (string ID, string name, S Tring Summary, String ImagePath, String category, double stars, String tileimagepath): Base (ID, name, Summ ary, ImagePath) {this. Category = Category This. Stars = stars; This. Projects = new observablecollection<project> (); This. Images = new Imagehelper (); This. Tileimagepath = Tileimagepath; public string Tileimagepath {get; set;} public string Category {get; set;} Public double Stars {get; set;} Public observablecollection<project> Projects {get; set;} public int Clicktimes {get; set;} Compatible with public imagehelper Images {get; set;} }}
Note that the namespace used for the same tile are:
using Windows.Data.Xml.Dom;using Windows.UI.Notifications;using System.Threading.Tasks;