BitmapSource to UI Element for FixedDocument?

1k views Asked by At

I have the following in a WPF application:

  1. Create a stackpanel
  2. Create a bitmapsource from the stackpanel
  3. Create a FixedDocument

So, I'm trying to get from step 2 to step 3. FixedDocuments only accept UIElement objects for Children.Add. Is there a way to get from a bitmapsource to a UIElement (or some other object) that will be accepted by a FixedDocuemnt? Yes, I realize that a Stackpanel is a UIElement and I could add that to my document but I prefer to add it as an image.

1

There are 1 answers

0
Mike On

I believe you are looking for System.Windows.Controls.Image. Given BitmapSource bs

Image anImage = new Image();
anImage.Source = bs;

should do the trick to get from 2. to 3.