How can I bind source MediaCapture to CaptureElement using Caliburn.Micro?

后端 未结 4 1708
春和景丽
春和景丽 2021-02-10 22:12

On Windows Phone 8.1, I am using the Caliburn.Micro view-model-first approach, but as the view model cannot have any knowledge of the view, I cannot see how I can bind a MediaCa

4条回答
  •  無奈伤痛
    2021-02-10 22:46

    Adding to Hawlett's answer, I had to do a little bit more to get the camera displaying correctly. I have changed ConfigureMedia() to be:

    private async void ConfigureMedia()
    {
        _deviceInformationCollection = await DeviceInformation.FindAllAsync(DeviceClass.VideoCapture);
        await MediaCapture.InitializeAsync(new MediaCaptureInitializationSettings
        {
            VideoDeviceId = _deviceInformationCollection[_deviceInformationCollection.Count - 1].Id
            // The rear-facing camera is the last in the list
        });
        MediaCapture.VideoDeviceController.PrimaryUse = CaptureUse.Photo;
        MediaCapture.SetPreviewRotation(VideoRotation.Clockwise90Degrees);
        CaptureElement.Source = MediaCapture;
        CaptureElement.Stretch = Stretch.UniformToFill;
        await MediaCapture.StartPreviewAsync();
    }
    

提交回复
热议问题