0

(ユーザーがアプリをピン留めした後) 開始時に表示されるカスタム ShellTile を作成する方法はありますか? カウント数 (ラベル) のサイズと位置を変更したいのですが、その方法が見つかりません。

4

1 に答える 1

3

タイトルまたはカウンターの位置またはスタイルを変更することはできませんが、タイルに表示する画像を生成できます。次に例を示します。

WriteableBitmap bitmap = new WriteableBitmap(173, 173);

TextBlock textBlock = new TextBlock();
textBlock.TextWrapping = TextWrapping.Wrap;
textBlock.Foreground = new SolidColorBrush(Colors.White);
textBlock.FontSize = 22.0;
textBlock.Margin = new Thickness(12.0, 8.0, 8.0, 45.0);
textBlock.Text = "Lorem ipsum";
textBlock.HorizontalAlignment = HorizontalAlignment.Stretch;
textBlock.VerticalAlignment = VerticalAlignment.Stretch;

Grid layoutRoot = new Grid();
layoutRoot.Background = (Brush)App.Current.Resources["PhoneAccentBrush"];
layoutRoot.Width = 173.0;
layoutRoot.Height = 173.0;
layoutRoot.Children.Add(textBlock);

layoutRoot.Measure(new Size(173, 173));
layoutRoot.Arrange(new Rect(0, 0, 173, 173));
layoutRoot.UpdateLayout();
bitmap.Render(layoutRoot, null);
bitmap.Invalidate();

using (IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication())
{
    string fileName = "/Shared/ShellContent/BackgroundImage.jpg";
    using (Stream fileStream = storage.CreateFile(fileName))
    {
        bitmap.SaveJpeg(fileStream, 173, 173, 0, 100);
    }
}

StandardTileData tileData = new StandardTileData
{
    BackgroundImage = new Uri("isostore:"/Shared/ShellContent/BackgroundImage.jpg, UriKind.Absolute),
    Title = "Lorem Ipsum,
};

ShellTile.Create(new Uri("/MainPage.xaml", UriKind.Relative), tileData);
于 2012-03-11T21:44:35.090 に答える