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

后端 未结 4 1460
梦谈多话
梦谈多话 2021-02-10 22:03

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:38

    If you're trying to keep strict view / view model separation then there are couple of possibilities.

    Have you tried straight binding?

    
    

    If that doesn't work another one is create your own attached property that you could put on CaptureElement. When that property is set you can set the source yourself.

    
    

    Here's a sample of doing some similar with web view and creating an html binding.

    The way I tend to do this though is create an interface abstracting the view (say ICaptureView) that the view implements.

    I can then cast the view held by the view model

    var captureView = (ICaptureView) GetView();
    

    where ICaptureView implements a SetCaptureSource method. This way it's still testable as you can attach a mock ICaptureView to the view model for testing.

提交回复
热议问题