Webcam support was the most anticipated innovation and did not become news to anyone. It is relatively easy to activate this feature. The following example demonstrates a simple UI with a code that connects a webcam. This post does not affect work with several webcams, however, calling
CaptureDeviceConfiguration.GetAvailableVideoCaptureDevices , you get a list of all available webcams.
First, create a simple UI (
Rectangle and
Button ).

Add a button click event. The logic looks like this:
- Get the handler of your video capture device using CaptureDeviceConfiguration .
- Request access to the CaptureDeviceConfiguration.RequestDeviceAccess () device.
- If the user has confirmed access, create a CaptureSource object and then set the VideoCaptureDevice to the selected webcam.
- Create a VideoBrush .
- Set the source of the video brush ( VideoBrush ).
- Launch the webcam.
- Draw a Rectangle (you can use any objects that take a brush (Brush))

')
The next step is to launch the application. You will see a blank screen with a button, after clicking on it, a request window will open to allow the program to use the webcam and microphone. Of course, click "Yes";).

Voila! .. Now you look at yourself, and maybe at the wall or ceiling.

After launching the application, I noticed a mirroring, so that the application would show the image as a mirror, set
Flip rectangl by X excise. Here’s what this menu looks like in Blend:
