Pergunta

I have a hubtile in my application which opens contacts for dialling a number. Now, i wanted to pin that into the start page of windows and i am implementing this feature by using the below code:

private void Click_Tap(object sender, RoutedEventArgs e)
    {
        ShellTile oTile = ShellTile.ActiveTiles.FirstOrDefault(x =>               
        x.NavigationUri.ToString().Contains("flip".ToString()));

        if (oTile != null && oTile.NavigationUri.ToString().Contains("flip"))
        {
            FlipTileData oFliptile = new FlipTileData();
            oFliptile.Title = "Hello WP8!!";
            oFliptile.Count = 11;
            oFliptile.BackTitle = "Updated Flip Tile";

            oFliptile.BackContent = "back of tile";
            oFliptile.WideBackContent = "back of the wide tile";

            oFliptile.SmallBackgroundImage = new Uri("Assets/Tiles/Flip/h.jpg", UriKind.Relative);
            oFliptile.BackgroundImage = new Uri("Assets/Tiles/Flip/h.jpg", UriKind.Relative);
            oFliptile.WideBackgroundImage = new Uri("Assets/Tiles/Flip/h.jpg", UriKind.Relative);
            oFliptile.BackBackgroundImage = new Uri("/Assets/Tiles/Flip/h.jpg", UriKind.Relative);
            oFliptile.WideBackBackgroundImage = new Uri("/Assets/Tiles/Flip/h.jpg", UriKind.Relative);
            oTile.Update(oFliptile);
            MessageBox.Show("Flip Tile Data successfully update.");
        }
        else
        {

            Uri tileUri = new Uri("/phoneNumberChooserTask.show()?tile=flip", UriKind.Relative);
            ShellTileData tileData = this.CreateFlipTileData();
            ShellTile.Create(tileUri, tileData, true);
        }
    }

    private ShellTileData CreateFlipTileData()
        return new FlipTileData()
        {
            Title = "",
            BackTitle = "",
            BackContent = "",
            WideBackContent = "",
            Count = 8,
           SmallBackgroundImage = new Uri("/Assets/Tiles/Flip/h.jpg", UriKind.Relative),
            BackgroundImage = new Uri("/Assets/Tiles/Flip/h.jpg", UriKind.Relative),
            WideBackgroundImage = new Uri("/Assets/Tiles/Flip/h.jpg", UriKind.Relative),
        };
    }

The problem i am facing is when i run this on a device/emulator, Tile gets pin to start but when i click the tile on the start screen of my device/emulator debugger stops the process and the process breaks.

Can anyone guide me in the right direction ?

Foi útil?

Solução

Tile can not launch anything except your app. Add into uri some code that will be parsed by your app and then your app should call phoneNumberChooserTask.show(). For example:

new Uri("/Chooser.xaml?tile=flip", UriKind.Relative);

Then, in the Chooser.xaml (page in your project), in the OnNavigatedTo detect the title value in the Uri and call phoneNumberChooserTask.show().

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top