Note that there are some explanatory texts on larger screens.

plurals
  1. POpin webbrowser instance to start screen
    primarykey
    data
    text
    <p>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</p> <p>MainPage.xaml.cs</p> <pre><code>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 =&gt; 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 &amp;&amp; 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 =&gt; x.NavigationUri.ToString().Contains("url=" + _url)); //ShellTile TileToFind = ShellTile.ActiveTiles.FirstOrDefault(x =&gt; 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); } //} } } </code></pre> <p>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 <a href="http://www.bing.com" rel="nofollow">http://www.bing.com</a>. 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.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload