The basic problem to solve is making MediaCapture, a UWP library item, related services available to WPF/MVVM/Framework applications without generating compile time cross platform warnings. I've been approaching that by writing a class in the Standard library
that exposes public properties of types that a Framework application can directly access. The latest problem (of many) is how to display an acquired photo in a WPF Image control. I'm having trouble converting the acquired image format converted into something
that can be displayed in a WPF Image control. As a possible alternative, I wouldn't be adverse to putting a ContentControl in the WPF View and then attaching a MediaCapture compliant control inside it as long as that can be accomplished in a WPF/MVVM compliant
basis (read: Code behind is evidence of demonic influence. Bad programmer. No hyper caffeinated sugar beverage.).
There is a button whose Command is handled in the WPF ViewModel. It makes a call into
public async void SnapAsync()
{
LowLagPhotoCapture lowLagCapture = await MediaCaptureMgr.PrepareLowLagPhotoCaptureAsync(ImageEncodingProperties.CreateUncompressed(MediaPixelFormat.Bgra8));
CapturedPhoto capturedPhoto = await lowLagCapture.CaptureAsync();
SoftwareBitmap softwareBitmap = capturedPhoto.Frame.SoftwareBitmap;
// Missing code here - how to make the convertion to
// an ImageSource or some other bitmap format that an Image.Source will accept.
CurrentImage = ????;
// Release resources now that the capture is done.
await lowLagCapture.FinishAsync();
}
Richard Lewis Haggard