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 7602255
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T23:21:58+00:00 2026-05-30T23:21:58+00:00

Basically what I am trying to accomplish is to pin a webbrowser instance to

  • 0

Basically what I am trying to accomplish is to pin a webbrowser instance to my windows phone start screen, and then when someone wants to go back to the specific site that was pinned, the user will click on the tile and be taken to that same webpage within my application when the application reloads. I have researched this functionality all over the internet and have not found any utilization of this, but I have seen this performed on a few apps in the marketplace.
I have attempted to reference someone’s implementation of something similiar using a querystring to get the required data to tell the application how to load from the secondary tile, but I may have something incorrect. Also, I can tell the secondary tile to load up the main page in my application which contains a webbrowser control, but I have not figured out how I can send a link to the webbrowser control (via querystring?) to load a particular webpage. My code thus far is as follows

MainPage.xaml.cs

public partial class MainPage : PhoneApplicationPage
{
    //for 'pin to start' webbrowser instance
    private const string _key = "url";
    private string _url;

    // Constructor
    public MainPage()
    {
        InitializeComponent();
    }


    //OnNavigatedFrom method
    protected override void OnNavigatedFrom(NavigationEventArgs e)
    {
        //base.OnNavigatedFrom(e);
        try
        {
            if (_url != null)
            {
                this.State[_key] = new MainPage
                {
                    _url = TheBrowser.Url.AbsoluteUri.ToString()
                };
            }

        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message);
        }

    }


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

        // See whether the Tile is pinned
        // (User may have deleted it manually.)
        //ShellTile TileToFind = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains("DefaultTitle=FromTile"));


        //for "pin to start" webbrowser instances
        //if this page was activated from a tile, launch a request for the current 
        //web address at the location indicated in the query string
        if (NavigationContext.QueryString.ContainsKey(_key))
        {
            string url = NavigationContext.QueryString[_key];

            //if url is absoluteuri, open webbrowser and direct to absoluteuri
            if (!TheBrowser.InitialUri.Equals(TheBrowser.InitialUri))
            {
                TheBrowser.Navigate(url);
            }

            //remove the url from the querystring (important!!)
            NavigationContext.QueryString.Remove(_key);
        }

        //otherwise check to see if the app needs to be untombstoned
        //and restore it to its pretombstoned state if it does
        //else if (_url == null)
        else if (_url == null && this.State.ContainsKey(_key))            
        {
            MainPage mainPage = this.State[_key] as MainPage;
            //TheBrowser.Navigate(TheBrowser.InitialUri);
            _url = (string)mainPage.State[_key];
            TheBrowser.Navigate(_url);
        }
    }    


    //Application Tile
    private void SetApplicationTile(object sender, EventArgs e)
    {
        int newCount = 0;
        string appName = "Quest";

        // Application Tile is always the first Tile, even if it is not pinned to Start.
        ShellTile TileToFind = ShellTile.ActiveTiles.First();

        // Application should always be found
        if (TileToFind != null)
        {
            // Set the properties to update for the Application Tile.
            // Empty strings for the text values and URIs will result in the property being cleared.
            StandardTileData NewTileData = new StandardTileData
            {
                Title = appName,
                BackgroundImage = new Uri("/Background.png", UriKind.Relative),
                Count = newCount,
                BackTitle = appName,
                BackBackgroundImage = new Uri("", UriKind.Relative),
                BackContent = "flipside"
            };

            // Update the Application Tile
            TileToFind.Update(NewTileData);
        }

    }

    //Secondary Tile(s)
    private void PinToStart_Click(object sender, EventArgs e)
    {             
        //Look to see whether the Tile already exists and if so, don't try to create it again.
        // if the Tile doesn't exist, create it

        //if (!String.IsNullOrEmpty(_url))
        //{
            // Look to see whether the Tile already exists and if so, don't try to create it again.
            ShellTile TileToFind = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains("url=" + _url));
            //ShellTile TileToFind = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains("_url"));

            // Create the Tile if we didn't find that it already exists.
            if (TileToFind == null)
            {
                StandardTileData NewTileData = new StandardTileData
                {
                    BackgroundImage = new Uri("Background.png", UriKind.Relative),
                    Title = "link",
                    Count = 1,
                    BackTitle = "Quest",
                    BackContent = (string)_url,
                    BackBackgroundImage = new Uri("", UriKind.Relative)
                };

                // Create the Tile and pin it to Start. This will cause a navigation to Start and a deactivation of our application.
                ShellTile.Create(new Uri("/MainPage.xaml?" + _key + "=" + _url, UriKind.Relative), NewTileData);
                //ShellTile.Create(new Uri("/MainPage.xaml?_url", UriKind.Relative), NewTileData);
            }                  
        //}
    }
}

As you can see, I am new to the secondary tile creating and implementation. I have been playing around with the correct structure, and I am attempting to use a querystring to pass the url with the secondary tile to load the webbrowser on MainPage.xaml with the correct website. What I have so far actualy does create a secondary tile and does bring me back to the MainPage.xaml but with a new instance of my webbrowser which is set to an initialuri of http://www.bing.com.
Any help with this would be GREATLY appreciated. I have been working on this for a while and have seen several ways to create the secondary tile for certain xaml pages, but nothing requiring loading a webbrowser control with a certain url. I need to implement this solution quickly! Could you please also include changes in code because I am definately a newcomer to wp7! Thanks in advance for your much appreciated help.

  • 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-05-30T23:21:59+00:00Added an answer on May 30, 2026 at 11:21 pm

    I’m one of the dev’s on MegaTile (which does exactly what you describe above).

    We have two pages:

    • Main.xaml – this does the management of the tiles and setting up the actions
    • CallbackHandler.xaml – this handles the launch from the secondary tiles.

    When we are creating a new tile (your PinToStart_Click) we create the callback as:

    ShellTile.Create(new Uri("/CallbackHandler.xaml?Action=" + _action, UriKind.Relative), NewTileData);
    

    Then in the CallbackHandler.xaml.cs PhoneApplicationPage_Loaded we do the appropriate action:

    try
    {
        UriBuilder b = new UriBuilder(extraData);
        new WebBrowserTask { Uri = b.Uri }.Show();
    }
    catch (Exception ex)
    {
       // something useful
    }
    

    Edit: a bit more time so I made your example work:

    XAML:

    <!--ContentPanel - place additional content here-->
    <StackPanel x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0" >
         <TextBox x:Name="url" Text="http://www.linknode.co.uk" />
         <Button Content="Create Tile" Click="PinToStart_Click" />
         <phone:WebBrowser x:Name="TheBrowser" Height="400" />
    </StackPanel>
    

    c#

    public partial class MainPage : PhoneApplicationPage
    {
    
        private const string _key = "url";
    
        // Constructor
        public MainPage()
        {
            InitializeComponent();
        }
    
        //OnNavigatedTo method
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            //if this page was activated from a tile it will contain a Querystring value of _key
            // launch a request for the current web address at the location indicated in the query string
            if (NavigationContext.QueryString.ContainsKey(_key))
            {
                string url = NavigationContext.QueryString[_key];
                TheBrowser.Navigate(new Uri(url));
            }
        }
    
    
        private void PinToStart_Click(object sender, RoutedEventArgs e)
        {
            string _url = url.Text;
    
            ShellTile TileToFind = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains("url=" + _url));
    
            // Create the Tile if we didn't find that it already exists.
            if (TileToFind == null)
            {
                StandardTileData NewTileData = new StandardTileData
                {
                    BackgroundImage = new Uri("Background.png", UriKind.Relative),
                    Title = string.Format("link - {0}", _url),
                    Count = 1,
                    BackTitle = "Quest",
                    BackContent = (string)_url,
                    BackBackgroundImage = new Uri("", UriKind.Relative)
                };
    
                // Create the Tile and pin it to Start. This will cause a navigation to Start and a deactivation of our application.
                ShellTile.Create(new Uri("/MainPage.xaml?" + _key + "=" + _url, UriKind.Relative), NewTileData);
            }
            else
            {
                MessageBox.Show("Tile already exists");
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically I'm trying to accomplish the same thing that mailto:bgates@microsoft.com does in Internet Explorer
Right what im trying to accomplish is a program that basically sets the active
I am stuck with using Dojo to accomplish this. Basically what I am trying
Basically what I am trying to accomplish is create a list of images (let's
I'm basically trying to accomplish the following. I want it so 5 seconds after
What I'm trying to accomplish is basically hide the fact that the page is
Check out this picture to see what I am trying to accomplish. Basically I
Here's a screenshot of what I'm trying to accomplish: Basically, if the user chooses
Basically what I'm trying to accomplish is I want to check multiple dynamic forms
Basically what I am trying to accomplish is I want a canvas I can

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.