Windows Phone 7 study notes 5 tilesample

Source: Internet
Author: User
WP 7 is an applicationProgramSet as tile.
 
 
 Using System; Using System. Collections. Generic; Using System. LINQ; Using System. net; Using System. windows; Using System. Windows. controls; Using System. Windows. documents; Using System. Windows. input; Using System. Windows. Media;Using System. Windows. Media. animation; Using System. Windows. shapes; Using Microsoft. Phone. controls; Using Microsoft. Phone. shell; Namespace Wptilesample { Public partial class  Mainpage : Phoneapplicationpage { // Constructor  Public Mainpage () {initializecomponent ();} Private Static readonly string Secondarytileurisource = "Source = seconarytile" ; Protected override void Onnavigatedto (system. Windows. navigation. Navigationeventargs E ){ Base . Onnavigatedto (E ); // Check whether the current tile is used  Shelltile Secondarytile = This . Findtile (secondarytileurisource ); This . Cbshowtile. ischecked = secondarytile! = Null ;}/// <Summary> ///  Check whether the current name is in the tile.  /// </Summary> /// <Param name = "partofuri"> </param> /// <returns> </returns>  Private  Shelltile Findtile ( String Partofuri ){ // Whether the current program is a tile  Shelltile Shelltile = Shelltile . Activetiles. firstordefault (tile => tile. navigationuri. tostring (). Contains (partofuri )); Return Shelltile ;} Private void Cbshowtile_checked ( Object Sender, Routedeventargs E ){ // Secondary tiles can be created only as the result // of user input in an application  Shelltile Tile = This . Findtile (secondarytileurisource ); If (Tile = Null ){// Because the UI will navigate to start // when a new secondary tile is created // only one secondary tile can be created at a time  Standardtiledata Tiledata = This . Getsecondarytiledata (); // Having a unique navigationuri is necessary for distinguishing this tile  String Tileuri = String . Concat ( "/Mainpage. XAML? " , Secondarytileurisource ); Shelltile . Create ( New Uri (Tileuri, Urikind . Relative), tiledata );}} // Delete a tile  Private void Cbshowtile_unchecked ( Object Sender, Routedeventargs E ){ Shelltile Tile = This . Findtile (secondarytileurisource ); If (Tile! = Null ) {Tile. Delete (); MessageBox . Show ( "Secondary tile deleted ." );}} /// <Summary> ///  Set Tile  /// </Summary> /// <returns> </returns>  Private  Standardtiledata Getsecondarytiledata (){ Standardtiledata Tiledata = New  Standardtiledata {Title = "Secondary tile" , Backgroundimage =New  Uri ( "/Images/logo.png" , Urikind . Relative), Count = 5, backtitle = "Secondary tile" , Backbackgroundimage = New  Uri ( "" , Urikind . Relative), backcontent = "WPG Add Remove tile sample" }; Return Tiledata ;}}}

 

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.