0

我目前有下面的代码,可以为 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);
4

1 回答 1

0

ShellTile 具有额外的 create 重载,允许可选的布尔参数指定是否支持宽平铺。您需要使用它来支持宽瓷砖。

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

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

顺便说一句,您需要使用新的平铺模板之一,例如 FlipTileData 并通过它。StandardTileData 不支持wide,继承自#wp7.5

http://msdn.microsoft.com/en-us/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);
于 2013-06-22T15:45:29.583 回答