簡體   English   中英

Windows Phone 8中的自定義寬塊

[英]Custom Wide Tile in Windows Phone 8

我目前有下面的代碼為Tile創建自定義布局。 它僅調整為中小型而非大型。

我需要更新代碼以支持Windows Phone 8的廣泛功能,但我需要能夠自定義文本的顯示位置。

該代碼使用一個模板,可以在其中更改圖塊的背景和文本的位置。

關於如何使它變得更寬泛的任何想法? 而且還可以輸出多行文本。

  ShellTile TileToFind = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains(busStopName.Text));


            TileControl frontTile = new TileControl();
            TileName = "";
            TileName = busStopName.Text;
            TileData tileData = new TileData() {Text1 = busStopName.Text };
            frontTile.DataContext = tileData;

            frontTile.Measure(new Size(173, 173));
            frontTile.Arrange(new Rect(0, 0, 173, 173));
            var bmp = new WriteableBitmap(173, 173);
            bmp.Render(frontTile, null);
            bmp.Invalidate();

            var isf = IsolatedStorageFile.GetUserStoreForApplication();
            var filename = "/Shared/ShellContent/" + busStopName.Text + ".jpg";

            using (var stream = isf.OpenFile(filename, System.IO.FileMode.OpenOrCreate))
            {
                bmp.SaveJpeg(stream, 173, 173, 0, 100);
            }

            var data = new StandardTileData
            {
                BackgroundImage = new Uri("isostore:/Shared/ShellContent/" + busStopName.Text + ".jpg", UriKind.Absolute)
            };

            ShellTile.Create(new Uri("/LiveTimes.xaml?name=" + busStopName.Text, UriKind.Relative), data);

ShellTile具有額外的創建重載,該重載允許使用可選的布爾參數指定是否支持寬瓦片。 您需要使用它來支持寬塊。

看看我的博客文章http://invokeit.wordpress.com/2013/05/09/fliptile-cycletile-and-various-iterations-of-wpdev-sdks/

http://msdn.microsoft.com/zh-CN/library/windowsphone/develop/jj207919(v=vs.105).aspx

順便說一句,您需要使用新的圖塊模板之一,例如FlipTileData並將其傳遞。 StandardTileData無法支持廣泛,並且是從#wp7.5繼承的

http://msdn.microsoft.com/zh-CN/library/windowsphone/develop/jj206971(v=vs.105).aspx

FlipTileData TileData = new FlipTileData()
{
   Title = "[title]",
   BackTitle = "[back of Tile title]",
   BackContent = "[back of medium Tile size content]",
   WideBackContent = "[back of wide Tile size content]",
   Count = [count],
   SmallBackgroundImage = [small Tile size URI],
   BackgroundImage = [front of medium Tile size URI],
   BackBackgroundImage = [back of medium Tile size URI],
   WideBackgroundImage = [front of wide Tile size URI],
   WideBackBackgroundImage = [back of wide Tile size URI],
};

ShellTile.Create(new Uri("/LiveTimes.xaml?name=" + busStopName.Text, UriKind.Relative), TileData, true);

暫無
暫無

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

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