1

I have a problem with a live tile. I would show in live tile the name of songs in a my app that generates sounds. I used in MainPage.xaml.cs:

public MainPage()
    {
        InitializeComponent();
        // 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)
        {
            // if Count was not entered, then assume a value of 0

            // 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 = "MyNameApp",
                BackgroundImage = new Uri("Red.jpg", UriKind.Relative),

                BackTitle = "Zzz...",
                BackBackgroundImage = new Uri("Green.jpg", UriKind.Relative),
                BackContent = txtCurrentTrack.Text <<HERE MY PROBLEM
            };

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


    }

and in MainPage.xaml:

<TextBlock x:Name="txtCurrentTrack" Height="75" HorizontalAlignment="Center" Margin="12,193,0,0" VerticalAlignment="Top" Width="438" TextWrapping="Wrap"/>

In App's MainPage the title of song appears instead in live tile doesn't appear. Do you know what is the problem? Thnx to all

EDIT:

I set txtcurrentTrack.Text here (in MainPage.xaml.cs):

void Instance_PlayStateChanged(object sender, EventArgs e)
    {
        switch (BackgroundAudioPlayer.Instance.PlayerState)
        {
            case PlayState.Playing:
                RelaxTB.Content = "pause";
                break;

            case PlayState.Paused:
            case PlayState.Stopped:
                RelaxTB.Content = "play";
                break;
        }
        if (null != BackgroundAudioPlayer.Instance.Track)
        {
            txtCurrentTrack.Text = BackgroundAudioPlayer.Instance.Track.Title;
        }
    }
    protected override void OnNavigatedTo(NavigationEventArgs e)
    {
        if (PlayState.Playing == BackgroundAudioPlayer.Instance.PlayerState)
        {
            RelaxTB.Content = "Pause";
            txtCurrentTrack.Text = BackgroundAudioPlayer.Instance.Track.Title;

        }
        else
        {
            RelaxTB.Content = "Play";
            txtCurrentTrack.Text = "";
        }
    }
Develobeer
  • 425
  • 1
  • 8
  • 19
  • have you tried debugging to make sure that the BackContent property of StandardTileData is set? – Igor Ralic Aug 09 '12 at 19:29
  • Yes. If I write in BackContent a string for example BackContent="example", it works. Instead if I write txtCurrentTrack.Text it doesn't work. However I edited the code where I show where I set txtCurrentTrack.Text – Develobeer Aug 09 '12 at 23:13

1 Answers1

0

The Text property on txtCurrentTrack does not appear to be set at the point that you update the tile data. Therefore you can only be setting the BackContent property to null.

You need to update the tile explicitly each time you change txtCurrentTrack.Text - in the Instance_PlayStateChanged and OnNavigatedTo methods.

Silver Solver
  • 2,310
  • 1
  • 13
  • 19
  • As TriggerPin indicated, you are only setting BackContent and the tile data in the constructor of MainPage. When txtCurrentTrack.Text is updated, you are not doing anything to update the live tile as well. – Gambit Aug 10 '12 at 07:19