Mare Infinitus
Mare Infinitus

Reputation: 8172

Load Imagesource into Control

I need an instance of System.Windows.Controls.Control which displays an image. But all i have is an imagesource.

I can use

var image = new Image();
image.Source = imageSource;

but, besides Image is in the Controls namespace, it is itself not derived from Control.

Is there an easy way to get the Imagesource programmatically into a control?

Upvotes: 1

Views: 134

Answers (1)

Trevor Elliott
Trevor Elliott

Reputation: 11252

You could wrap it in a ContentControl.

ContentControl cc = new ContentControl();
cc.Content = image;

But I'm really curious why you need a Control.

Upvotes: 1

Related Questions