DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
11 Monitoring and Observability Tools for 2023
Learn more
  1. DZone
  2. Testing, Deployment, and Maintenance
  3. Maintenance
  4. How to Debug a Windows 8 Metro Secondary Tile

How to Debug a Windows 8 Metro Secondary Tile

Jeremy Likness user avatar by
Jeremy Likness
·
May. 20, 12 · Interview
Like (0)
Save
Tweet
Share
4.66K Views

Join the DZone community and get the full member experience.

Join For Free

i've been working on chapter 7 of my upcoming book, designing windows 8 metro applications with c# and xaml . this chapter focuses on tiles and toast notifications. in the windows 8 runtime, it is incredibly easy to prompt the user to pin a secondary tile. this is a tile that has a deep link for content. for example, my reference application contains blogs and blog posts from several wintellect employees. you can pin a specific blog or even a specific item within a blog. the application bar provides the icon to click to pin to start :

the code simply grabs the current "group" that represents a blog, then formats a unique id for the tile, a title, and a special set of arguments that are passed when the tile is tapped:

private void pin_click_1(object sender, routedeventargs e)
{
    var group = defaultviewmodel["group"] as bloggroup;
    var title = string.format("blog: {0}", group.title);            
    ((app)application.current).pintostart(this,
        string.format("wintellog.{0}", group.id.gethashcode()),
        title,
        title,
        string.format("group={0}", group.id));
}

the code on the app class that does the actual work simply sets up some assets for the tile, computes the location of the button that was tapped and then sets up the tile to prompt the user to pin it:

public async void pintostart(object sender, string id, string shortname, string displayname, string args)
{
    var logo = new uri("ms-appx:///assets/logo.png");
    var smalllogo = new uri("ms-appx:///assets/smalllogo.png");
    var widelogo = new uri("ms-appx:///assets/widelogo.png");
    var tile = new secondarytile(id, shortname, displayname, args, tileoptions.shownameonlogo | tileoptions.shownameonwidelogo,
        logo);
    tile.foregroundtext = foregroundtext.dark;
    tile.smalllogo = smalllogo;
    tile.widelogo = widelogo;            

    var element = sender as frameworkelement; 
    var buttontransform = element.transformtovisual(null);
    var point = buttontransform.transformpoint(new point());
    var rect = new rect(point, new size(element.actualwidth, element.actualheight));

    await tile.requestcreateforselectionasync(rect, windows.ui.popups.placement.left);        
}

you can see what the prompt looks like here:

when the application launches, it can read the arguments that are passed in and use them to navigate to the deep link:

if (_activationargs.arguments.startswith("group"))
{
    var group = _activationargs.arguments.split('=');
    target = typeof(groupdetailpage);
    parameter = list.where(g => g.id.equals(group[1])).firstordefault();
}

the problem that you may encounter when dealing with secondary tiles is that the arguments are read-only when the application is launched. if you launch your metro application from the debugger, you cannot modify the arguments and they will be passed in as blank. this will cause the application to respond as if it were launched from the primary tile, not a secondary one. fortunately, the solution to debug secondary tiles is very straightforward. simply right-click on the metro project in the solution explorer and navigate to the debug tab. there, you can set the application to get ready for debugging but not actually launch when you start a debugger session. this is what the setting looks like (see do not launch, but debug my code when it starts ):

once you check this setting, you can launch debug and the application will simply wait. then, you can press the windows key to open the start screen and launch the application from a secondary tile. when the application is launched, it will jump into the debugger and you can hit your breakpoints to see the secondary tile arguments passed in and troubleshoot any issues you may have. please head over to the facebook page for my upcoming book and "like" it to receive updates and learn when it will be available for preview online and released to print. i'll be handing out sample chapters at my upcoming speaking events, so i hope to see you there at one of them.

jeremy likness

Debug (command) application

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • What Is API-First?
  • Introduction to Automation Testing Strategies for Microservices
  • The 5 Books You Absolutely Must Read as an Engineering Manager
  • OWASP Kubernetes Top 10

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: