繁体   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