簡體   English   中英

更新Live Tile,但這是哪一個?

[英]Update Live Tile but which one is that?

我有一個帶有固定輔助活動磁貼的應用程序,它們在磁貼的背面顯示天數,我想減少每天的天數。 現在的問題是,我不想更改圖塊的其他屬性(因此,標題,圖像等),而僅FlipTileData.BackContent背面的內容(字符串): FlipTileData.BackContent所以我不想創建新的FlipTileData將其作為Update方法的參數傳遞。

第二個問題:我什至不知道要更新哪個圖塊? 我已經試過了:

foreach (ShellTile tile in ShellTile.ActiveTiles)但是foreach (ShellTile tile in ShellTile.ActiveTiles)貼沒有屬性可以提供幫助。 我應該使用NavigationUri找出那是哪個圖塊?

遵循此示例,在Windows Phone 7中使用活動磁貼 ,它將解決您的問題。

請注意代碼上的x.NavigationUri.ToString().**Contains("Title=SecondaryTile")**

編輯:

結合該網站的幾行代碼:

// modify Application Secondary Tile data
private void updateTile_Click(object sender, RoutedEventArgs e)
{

    // get application specific tile - EXAMPLE
    ShellTile Tile = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains("Title=SecondaryTileEXAMPLE_TITLE"));
    if (null != tile)
    {
        // create a new data for tile
        StandardTileData data = new StandardTileData();
        // tile foreground data
        data.Title = "Title text here";
        data.BackgroundImage = new Uri("/Images/Blue.jpg", UriKind.Relative);
        data.Count = random.Next(99);
        // to make tile flip add data to background also
        data.BackTitle = "Secret text here";
        data.BackBackgroundImage = new Uri("/Images/Green.jpg", UriKind.Relative);
        data.BackContent = "Back Content Text here...";
        // update tile
        tile.Update(data);
    }
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM