"Miles Journey--windows App development" Live tile

Source: Internet
Author: User

What is the dynamic tile, I believe you have spent so long windows 8/8.1/10 already know very well.

Like what small tile, medium tile, wide tile, big tile, and the App Store logo, and so on, you can choose the right picture according to different resolutions.

Here's a feature to update the tile page, which is the page XML section.

<StackPanel Margin=" a" >      <StackPanel Orientation="Horizontal">          <TextBlock FontSize="+" Text="Select Template:" VerticalAlignment ="Center"/>          <ComboBox x:name="Comboboxtile"Width=" the" SelectionChanged="comboboxtile_selectionchanged"/>        </StackPanel>      <textbox  x:Name  =< Span class= "Hljs-value" > "Textboxxml"  textwrapping  =  "Wrap"  fontsize  = "all"   Header  = "XML document"  width  =  "420"  height  = "
     
       class= Hljs-attribute HorizontalAlignment 
      = "left"  margin  =< Span class= "Hljs-value" > "n" />       <button Name= "btntile"Content="Update tile" click =" Btntile_click " Style=" {StaticResource Styletoastbutton} "/>  </StackPanel>

In the main function of the background code, get the Tiletemplatetype enumeration and bind to the ComboBox.

var itemsTile = Enum.GetNames(typeof(TileTemplateType));this.comboBoxTile.ItemsSource = itemsTile;

The following code is really similar to the previous toast, so I joined the two sections to write. button in the Click event, build an XML as before, and then load into an instance of the Tilenotification class. The last is the Tileupdatemanager class, which is the tile update.

Private void Btntile_click(Objectsender, RoutedEventArgs e) {if( This. Textboxxml.text = ="")return; XmlDocument Xdoc =NewXmlDocument (); Xdoc. LOADXML ( This. Textboxxml.text); Tilenotification Tilenotifi =NewTilenotification (Xdoc); Tileupdatemanager.createtileupdaterforapplication (). Update (Tilenotifi);}Private void comboboxtile_selectionchanged(Objectsender, SelectionChangedEventArgs e) {tiletemplatetype tiletemplate = (tiletemplatetype) enum.parse (typeof(Tiletemplatetype), This. Comboboxtile.selecteditem as string); XmlDocument Xdoc = tileupdatemanager.gettemplatecontent (tiletemplate); This. Textboxxml.text = Xdoc. GetXml ();}

Of course, if your app is not content with a tile, you can also create a second tile yo!

Still like the XML for Toast notifications, it also has a lot of attributes ...

Arguments: This string parameter is passed to the Onlaunched method of the application class when the application is launched through the secondary tile, so that the application can perform specific actions based on the parameters passed in.

BackgroundColor: Sets the background color of the tile.

DisplayName and ShortName: Sets the text that appears on the tile.

Logo, etc.: Set the icon for the tile, using the URI.

Foregroundtext: The color of the text on the tile, the available options are dark, light, and so on.

TileID: Sets the unique identity ID of the tile, before creating a new tile with secondarytile.exists to determine if it already exists.

In the Click event of the button that added the second tile:

Private Async void Btncreatetile(Objectsender, RoutedEventArgs e) {if(Secondarytile.exists (Texttileid.text)) {textblockmsg.text="The ID tile already exists";return; } Uri uriimg=NewUri ("Ms-appx:///assests/uriimg.png"); ...... ......//Create a second tileSecondarytile sectile=NewSecondarytile (); This.    Tag=sectile;    Sectile.displayname=textblockdisplayname.text;    Sectile.tileid=textblockid.text; sectile.arguments="Second";//Useful in the back    //Settings iconSectile.visualelements.backgroundcolor=windows.ui.colors.gold; ...... ......BOOLR=awaitSectile.requestcreateasync (); Textblockmsg.text=r = =true?"The tile was created successfully.":"Tile creation failed, eh.";//Return test results

If you want to click on a second tile to navigate to a specific page, you'll need to rewrite the page's Onnavigatedto method.

preteced async  override  void  onnavigatedto (NavigationEventArgs e) {if  (e.parameter is  Windows.ApplicationModel.Activation.LaunchActivatedEventArgs) {var  Arg=e.para        Meter as  Windows.ApplicationModel.Activation.LaunchActivateEventArgs; ...... }} if  (Rootframe.content==null ) {if  (E.arguments== "second" ) Rootframe.navigat    E (typeof  (otherpage), E); else  rootframe.navigate (typeof  (MainPage));} 

Here the parameter "second" is the above set that arguments oh, it is the role of this here.

Thank you for your visit and hope to help you. We welcome your attention, collection and comment.

To make this article get treatise and ask questions, reprint please indicate the source:
Http://blog.csdn.net/nomasp

"Miles Journey--windows App development" Live tile

Related Article

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.