Silverlight 4 - Render UIElement as an Image

后端 未结 4 481
不思量自难忘°
不思量自难忘° 2021-01-17 16:33

I have a UIElement that I want to capture a snapshot of when a user clicks a button. When a user clicks the button, I want to take the UIElement an

4条回答
  •  没有蜡笔的小新
    2021-01-17 17:12

    You can also do the following:

    private void SetImageSourceBasedOnElement(Image image, UIElement element)
    {
        if (element != null)
        {
            WriteableBitmap writableBitmap = new WriteableBitmap(element, null);
            writableBitmap.Invalidate();
    
            image.Source = writableBitmap;
         }
     }
    

提交回复
热议问题