1

ライブ タイルに問題があります。サウンドを生成するアプリの曲名をライブ タイルに表示します。私は 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);
        }


    }

そして MainPage.xaml で:

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

アプリの MainPage では、代わりに曲のタイトルが表示され、ライブ タイルには表示されません。何が問題か知っていますか?すべてにthnx

編集:

ここに txtcurrentTrack.Text を設定します (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 = "";
        }
    }
4

1 に答える 1

0

txtCurrentTrack の Text プロパティは、タイル データを更新した時点では設定されていないようです。したがって、BackContent プロパティを null に設定することしかできません。

You need to update the tile explicitly each time you change txtCurrentTrack.Text- Instance_PlayStateChanged および OnNavigatedTo メソッド内。

于 2012-08-09T19:56:45.613 に答える