2013-10-30 35 views
0

我正在開發一個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"); 
     } 
    } 

任何人都可以幫助我更新動態創建的磁貼。 謝謝。

+0

「我不能」是什麼意思?你有例外嗎? –

+0

@AntonSizikov嗨,謝謝你的回覆,「我不能」意思是,它沒有任何例外,我的代碼沒有任何異常,但我沒有發現我的瓷磚有任何變化,它仍然是一樣的。 – Noorul

回答

0

您的問題是 - 您正嘗試更新主磁貼,但您創建了輔助磁貼。主瓷磚永遠是第一個。

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

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

這是通過代碼創建的瓦片將被更新。

+0

嘿謝謝你的回覆,它的作品,,,,, – Noorul