渲染usercontrol live tile windows phone

时间:2013-01-16 11:26:12

标签: c# user-controls windows-phone writeablebitmap live-tile

看起来我设法通过在每次测量之前和之后调用我的usercontrol上的UpdateLayout并安排调用来解决它,到目前为止工作正常。如果有人有其他解决方案,请告诉我

我遇到类似于此问题的问题 post似乎用户已找到其背后的原因。我想知道除了创建一个堆栈面板以便在更新时正确渲染实时图块时是否还有其他解决方案?相同的代码在创建磁贴时工作正常但在更新时无法正确呈现。

这是我的方法:

 private void updateFrontTile()
    {
        var frontTile = new FrontMzaarTileControl();

        TileData tileData = new TileData()
        {
            temp= "1",
            temp2= "2",
            temp3= "3",
            temp4= "4",
            temp5= "5"
        };

        frontTile.DataContext = tileData;
        frontTile.Measure(new Size(691, 336)); // the user from the other post believes that this is not doing anything
        frontTile.Arrange(new Rect(0, 0, 691, 336)); // the user from the other post believes that this is not doing anything


        var bmp = new WriteableBitmap(691, 336);
        bmp.Render(frontTile, null);
        bmp.Invalidate();

        var isf = IsolatedStorageFile.GetUserStoreForApplication();
        FrontTileFilename = "/Shared/ShellContent/FrontTile.jpg";

        if (!isf.DirectoryExists("/Shared/ShellContent"))
        {
            isf.CreateDirectory("/Shared/ShellContent");
        }

        using (var stream = isf.OpenFile(FrontTileFilename, System.IO.FileMode.Create))
        {
            bmp.SaveJpeg(stream, 691, 336, 0, 100);
        } 
    }

0 个答案:

没有答案