簡體   English   中英

無法更新動態創建的實時圖塊

[英]Can't update dynamically created live tile

我正在開發Windows Phone的購物應用程序。

如果我手動固定圖塊,則可以通過代碼更新圖塊。

這是我的代碼來更新磁貼

 ShellTile TileToFind = ShellTile.ActiveTiles.First();

            StandardTileData NewTileData = new StandardTileData
            {
                BackgroundImage = new Uri(offer_mobile_image[0], UriKind.RelativeOrAbsolute),
                Count = NotificationCount,
                BackTitle = location_area,
                BackContent = offer_title,
            };


            TileToFind.Update(NewTileData);

如果我通過代碼動態創建活動磁貼,則無法更新磁貼

這是我用來創建實時圖塊的代碼

private void PinToStart()
    {
        StandardTileData standardTileData = new StandardTileData();
        standardTileData.BackgroundImage = new Uri(@"/ApplicationTile.png", UriKind.RelativeOrAbsolute);
        standardTileData.Title = "MyApplication";
        standardTileData.BackTitle = "this is my app";
        standardTileData.BackContent = "this is very good app";

        // Check if the application tile has already been defined - this is a tile that links to the app main page
        ShellTile tiletopin = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains("MainPage.xaml"));
        if (tiletopin == null)
        {
            //Create ShellTile linking to main page of app
            ShellTile.Create(new Uri("/MainPage.xaml", UriKind.Relative), standardTileData);
        }
        else
        {
            MessageBox.Show("Application is already Pinned");
        }
    }

誰能幫助我更新動態創建的圖塊。 謝謝。

您的問題是-您正在嘗試更新主圖塊,但是創建了輔助圖塊。 主圖塊始終是第一個。

如果您像這樣更新UpdateTile()方法:

ShellTile TileToFind = ShellTile.ActiveTiles.FirstOrDefault(
              x => x.NavigationUri.ToString().Contains("MainPage.xaml"));

通過代碼創建的圖塊將被更新。

暫無
暫無

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

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