Code for WPF WebCam
The sample code for the previous post is available here.
What would I change about this sample? The main thing is that the DirectShow initialisation occurs inside BuildWindowCore, which occurs very early in the creation of the UI. This initialisation could fail looking for a WebCam, or having found one fail to build a suitable graph. As the sample stands, the test application will not fail nicely. To handle these conditions, it would be better to have it behind an initialisation method so that a consumer of the control can control it and design a more graceful failure path.