Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8381723
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T16:45:25+00:00 2026-06-09T16:45:25+00:00

I have implemented secondary tiles in my application, so a user is able to

  • 0

I have implemented secondary tiles in my application, so a user is able to pin a secondary tile to the start screen, and then navigate to a respective page in my application accordingly. This implementation works ok, except for when the user hits the back hardware button after navigating to a specific page from the pinned secondary tile, nothing happens? In fact, for a quick second the previous page in the application is actually shown, although the user is coming from the start screen. What would be the proper method to actually return to the start screen as the user would expect would happen (I am assuming this would be the proper back stack navigation)?

What I have is as follows, but only works during normal page navigation scenarios, not when the user is navigating to the SharePage from the start screen pinned tile.

MainPage.xaml.cs

protected override void OnNavigatedTo(NavigationEventArgs e)
    {
        base.OnNavigatedTo(e);

        string _title = null;
        NavigationContext.QueryString.TryGetValue("Param", out _title);

        if (_title != null)
        {
            switch (_title)
            {
                case "status":
                    this.NavigationService.Navigate(new Uri("/Views/ShareStatusPage.xaml", UriKind.Relative));
                    break;
                case "link":
                    this.NavigationService.Navigate(new Uri("/Views/ShareLinkPage.xaml", UriKind.Relative));
                    break;
            }
        }            
    }

private void CreateLiveTile(TileItem item)
    {
        string tileParameter = "Param=" + item.Title.ToString();

        ShellTile Tile = CheckIfTileExist(tileParameter);  // Check if Tile's title has been used 

        if (Tile == null)
        {
            try
            {
                var LiveTile = new StandardTileData
                {
                    Title = item.TileName,
                    //BackgroundImage = ((System.Windows.Media.Imaging.BitmapImage)hubtile.Source).UriSource,
                    BackgroundImage = new Uri(item.ImageUri.ToString(), UriKind.Relative),
                    //Count = 1,
                    BackTitle = item.TileName,
                    //BackBackgroundImage = new Uri("", UriKind.Relative),
                    BackContent = item.Message,
                };

                ShellTile.Create(new Uri("/MainPage.xaml?" + tileParameter, UriKind.Relative), LiveTile);  //pass the tile parameter as the QueryString

            }
            catch (Exception)
            {
                MessageBox.Show("This tile could not be pinned", "Warning", MessageBoxButton.OK);
            }
        }
        else
        {
            MessageBox.Show("This tile has already been pinned", "Notice", MessageBoxButton.OK);
        }
    }

private ShellTile CheckIfTileExist(string tileUri)
    {
        ShellTile shellTile = ShellTile.ActiveTiles.FirstOrDefault(tile => tile.NavigationUri.ToString().Contains(tileUri));
        return shellTile;
    }

SharePage.xaml.cs

protected override void OnBackKeyPress(System.ComponentModel.CancelEventArgs e)
    {
        base.OnBackKeyPress(e);

        //return to the previous page in the phones back stack?
        if (NavigationService.CanGoBack)
        {
            e.Cancel = true;
            NavigationService.GoBack();
        }
        //else
        //{
        //    ??
        //}
    }

So far, CreateLiveTile() method creates the secondary tile and then when that tile is pressed, MainPage is navigated to and then the querystring is checked in the MainPage OnNavigatedTo event and the respective page is then loaded based on what secondary tile was clicked. Once this is performed and the respective pages has loaded, I can no longer press the back button to get back to the start screen to follow the standard backstack behavior. How can I fix this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T16:45:27+00:00Added an answer on June 9, 2026 at 4:45 pm

    According to your new update, lets have a look at this method:

    private void CreateLiveTile(TileItem item)
    {
        string tileParameter = "Param=" + item.Title.ToString();
         //...
    
        if (Tile == null)
        {
            try
            {
                var LiveTile = new StandardTileData
                {
                  //...
                };
    
                ShellTile.Create(new Uri("/MainPage.xaml?" + tileParameter, UriKind.Relative), LiveTile);  //pass the tile parameter as the QueryString
    
              //blah-blah-blah
    }
    

    Here you create a new tile and pass tileParameter to a MainPage. So, you navigate to main page, then detect the text in tile parameter, and navigate to the ShareLink or ShareStatus pages. That’s why you have a dirty navigation stack.

    Let me suggest you a way to avoid this situation:

    private void CreateLiveTile(TileItem item)
        {
    
        var title =  item.Title.ToString();
         //...
    
        if (Tile == null)
        {
            try
            {
                var LiveTile = new StandardTileData
                {
                  //...
                };
                 string page;
            switch (title)
            {
                case "status":
                    page = "/Views/ShareStatusPage.xaml";
                    break;
                case "link":
                    page = "/Views/ShareLinkPage.xaml");
                    break;
            }                
            if(string.IsNullOrEmpty(page))
             { 
                 //handle this situation. for example: page = "/MainPage.xaml";
             }
                ShellTile.Create(new Uri(page, UriKind.Relative), LiveTile); 
    
              //blah-blah-blah
    }
    

    When user taps on your secondary tile he will be navigated directly to ShareLink or ShareStatus page. And a NavigationStack will be clean. When the user press Back button, the application will be closed and user will see a start screen (this is a right back button behaviour for secondary tiles).

    p.s. Don’t forget to start all your services or load all resources if you have ones. Because MainPage won’t be created! Anyway every page of your application has to be able to itnitialize whole application, because you must support restoring from tombstoned state.

    Feel free to ask for details if you need.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have implemented a table view with multiple threads. Currently when a user taps
If I have Thread A which is the main Application Thread and a secondary
I have a WebKit-based application. When the user initiates an action that opens a
i have implemented a Runnable interface to load the image tiles and i want
Andy So I have this web application placed behind a loadbalancer. When a user
I implemented Facebook-Connect successfully and I'm able to retrieve User-Information using the Facebook Toolkit.
I have implemented correctly bump's api, and added this code: - (void) configureBump {
I have implemented pagination to my data, but the problem is I only have
I have implemented a test method with Jersey to run on my Google AppEngine
I have implemented Facebook into my app but now I find that whenever I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.