0

Windows Phoneアプリのセカンダリライブタイルで背景画像に問題が発生しています。タイルが適切に引き伸ばされてフィットしません(.png画像です)

データを取得してから、タイルデータを作成します。

var tileData = new StandardTileData
        {
            Title = titleString,
            BackContent = contentString,
            BackTitle = backTitleString,
            BackgroundImage = new Uri(httpUrlString)                
        };

タイルを変更または「再テンプレート化」する方法はありますか?

また、writeablebitmapを使用してここで解決策を見つけましたが、backgroundimageプロパティはURIのみを受け入れるため、このビットマップをソースとして指定する方法を理解できません。

4

2 に答える 2

2

You need to resize the image to give it the good aspect ratio (see the answer here)

Then you'll have to save the resulting WriteableBitmap in the Isolated Storage, like this:

        // save image to isolated storage
        using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication())
        {
            // use of "/Shared/ShellContent/" folder is mandatory!
            using (IsolatedStorageFileStream imageStream = new IsolatedStorageFileStream("/Shared/ShellContent/MyImage.jpg", System.IO.FileMode.Create, isf))
            {
                wbmp.SaveJpeg(imageStream, wbmp.PixelWidth, wbmp.PixelHeight, 0, 100);
            }
        }

You will then be able to create the tile like this:

        StandardTileData NewTileData = new StandardTileData
        {
            Title = "Title",
            // reference saved image via isostore URI
            BackgroundImage = new Uri("isostore:/Shared/ShellContent/MyImage.jpg", UriKind.Absolute),
        };
于 2012-09-11T06:43:42.497 に答える
1

問題は、画像が完全にロードされていなかったため、適切にレンダリングされなかったことです。ImageOpened イベントを使用し、Olivier が提案したように保存しました

于 2012-09-11T23:35:13.223 に答える