windowsphone8.1 Study Notes Tile

Source: Internet
Author: User

Tile, WP system unique. Personally, I think it's quite a force.

Okay, nonsense. Don't say much, let's create our own secondary tile. Creating a tile is a Secondarytile object, so let's start by talking about some of the important properties of the object.

Arguments property: A value is passed to the app, which allows the app to identify which tile clicked into it.

Backgroupcolor property, this property should be familiar with the name, is the background color of the tile.

DisplayName Property: The text information in the lower-left corner of the tile.

Visualelements Properties: Sets the display of the tile's visual properties.

Tileid Property: Represents the unique identity of the tile, which can be used to determine whether the tile exists and gets the tile object.

Samllogo, logo, and Widelogo properties: They represent the image addresses for small, medium, and wide three tiles

Uri Square71x71logo =NewUri ("Ms-appx:///assets/square71x71logo.scale-240.png"); Uri Square150x150logo=NewUri ("Ms-appx:///assets/logo.scale-240.png"); Uri Wide310x150logo=NewUri ("Ms-appx:///assets/widelogo.scale-240.png"); string tileId = "App1";stringTilearguments ="tileId"+"waspinnedat="+DateTime.Now.ToLocalTime (). ToString (); Secondarytile Secondarytile=NewSecondarytile (TileId,"titletest", Tilearguments, Square150x150logo, tilesize.square150x150); SecondaryTile.VisualElements.Wide310x150Logo=Wide310x150logo;secondarytile.visualelements.square150x150logo=Square150x150logo;secondarytile.visualelements.square71x71logo=Square71x71logo;secondarytile.visualelements.shownameonsquare150x150logo=true; SecondaryTile.VisualElements.ShowNameOnWide310x150Logo=true;BOOLispinned =awaitSecondarytile.requestcreateasync ();

Remind Me

Other actions for tiles:

//First Kindif(Secondarytile.exists (tileId)) {//Tiles exist for this tileid, you can create them through Tileid
Secondarytile Secondarytile =NewSecondarytile (tileId)
Delete a tile
BOOL Isdelete = await secondarytile.requestdeleteasync ();
Update Tile
Secondarytile.displayname= "Update Tile";
BOOL Success = await secondarytile.updateasync ();}//The second KindIreadonlylist<secondarytile> tileList =awaitSecondarytile.findallasync ();foreach(varTileinchtileList) { ......}

These are all nonsense, we take a look at the actual application of the secondary tile, for a simple example (their own understanding, not please leave a message), WP version of the Sohu news, we randomly point to a channel of their own subscription, you can see the red arrow button shown,

Click on the ' Start ' screen to generate the secondary tile as shown, when you click on the tile, you will be directly into the Sohu video hit page, of course, you can directly into the hit page because the value of secondarytile arguments plays a vital role

As follows:

<Grid> <button click="Button_Click"Horizontalalignment="Center"Verticalalignment="Center"Content="Create a tile"/> <textbox name="Testbox"textwrapping="Wrap"/></grid>

Set the value of secondarytile arguments when you create a tile
String tilearguments = "Go to the video hit page";
Secondarytile secondarytile = new Secondarytile (tileId, "Test", Tilearguments, Square150x150logo, TILESIZE.SQUARE150X150);

protected override void Onnavigatedto (NavigationEventArgs e)
{
Testbox.text = E.parameter.tostring ();
}

After clicking Create Tile, exit the program and click on the tile to run the effect as follows

All right, the secondary tile is simple.

Let's talk about live tiles, or tile notifications. In the previous article we mentioned toast notifications, simply say it and tile notifications.

Tile notifications can only be displayed on a tile and must have a tile, no sound or vibration, but it is possible to set the time it is displayed. A toast notification is displayed for only a few seconds and is a pop-up reminder. The way you create and the steps are similar, no longer detailed.

To create a tile notification step:

1. Get this sticker notification template

2. Add Content

3. Create a Tile notification object

4. Update the tile notification

XmlDocument Tilexml =tileupdatemanager.gettemplatecontent (tiletemplatetype.tilesquare150x150peekimageandtext02); XmlNodeList Tiletextattributes= Tilexml.getelementsbytagname ("text"); tiletextattributes[0]. InnerText ="Waha"; tiletextattributes[1]. InnerText ="Test the tile"; XmlNodeList Tileiamgeattributes= Tilexml.getelementsbytagname ("Image");((XmlElement) tileiamgeattributes[0]). SetAttribute ("src","Ms-appx:///assets/logo.scale-240.png"); Tilenotification tilenotification=Newtilenotification (tilexml); Tilenotification.expirationtime= DateTimeOffset.UtcNow.AddDays (1); Tileupdatemanager.createtileupdaterforapplication (). Update (tilenotification);

The Createtileupdaterforapplication method overloads are as follows, and when the parameter is Tileid, the specified secondary tile can be updated.

OK, so much for the tile, go eat!

windowsphone8.1 Study Notes Tile

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.