Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I'm one of the dev's on MegaTile (which does exactly what you describe above).</p> <p>We have two pages: </p> <ul> <li>Main.xaml - this does the management of the tiles and setting up the actions</li> <li>CallbackHandler.xaml - this handles the launch from the secondary tiles.</li> </ul> <p>When we are creating a new tile (your PinToStart_Click) we create the callback as:</p> <pre><code>ShellTile.Create(new Uri("/CallbackHandler.xaml?Action=" + _action, UriKind.Relative), NewTileData); </code></pre> <p>Then in the CallbackHandler.xaml.cs PhoneApplicationPage_Loaded we do the appropriate action:</p> <pre><code>try { UriBuilder b = new UriBuilder(extraData); new WebBrowserTask { Uri = b.Uri }.Show(); } catch (Exception ex) { // something useful } </code></pre> <p><strong>Edit</strong>: a bit more time so I made your example work:</p> <p>XAML:</p> <pre><code>&lt;!--ContentPanel - place additional content here--&gt; &lt;StackPanel x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0" &gt; &lt;TextBox x:Name="url" Text="http://www.linknode.co.uk" /&gt; &lt;Button Content="Create Tile" Click="PinToStart_Click" /&gt; &lt;phone:WebBrowser x:Name="TheBrowser" Height="400" /&gt; &lt;/StackPanel&gt; </code></pre> <p>c#</p> <pre><code>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 =&gt; 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"); } } } </code></pre>
    singulars
    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.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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