private void CreateImage()
{
FileStream fs = new FileStream("image.png", FileMode.Create);
RenderTargetBitmap bmp = new RenderTargetBitmap((int)bt.ActualWidth,
(int)bt.ActualHeight, 100, 100,
PixelFormats.Pbgra32);
bmp.Render(this.bt );
BitmapEncoder encoder = new PngBitmapEncoder();
encoder.Frames.Add(BitmapFrame.Create(bmp));
encoder.Save(fs);
fs.Dispose();
Close();
fs.Dispose();
}