我目前有以下代码为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);
答案 0 :(得分:0)
ShellTile具有额外的create重载,允许使用可选的Boolean参数指定是否支持宽tile。您需要使用它来支持宽瓷砖。
看看我的博客帖子 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);