Skip to content

Instantly share code, notes, and snippets.

@mbmccormick
Created December 19, 2013 18:12
Show Gist options
  • Save mbmccormick/8043676 to your computer and use it in GitHub Desktop.
Save mbmccormick/8043676 to your computer and use it in GitHub Desktop.
public void RenderLiveTileImage(string filename, string title, string content)
{
this.txtTitle.Text = title;
this.txtContent.Text = content;
this.Measure(new Size(336, 336));
this.Arrange(new Rect(0, 0, 336, 336));
this.UpdateLayout();
WriteableBitmap image = new WriteableBitmap(336, 336);
image.Render(this, null);
image.Invalidate();
using (IsolatedStorageFile output = IsolatedStorageFile.GetUserStoreForApplication())
{
using (var stream = output.OpenFile(filename, System.IO.FileMode.OpenOrCreate))
{
image.WritePNG(stream);
}
output.Dispose();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment