private static void MonikerString_Changed(DependencyObject sender, DependencyPropertyChangedEventArgs e)
{
// Get typed sender
CapDevice typedSender = sender as CapDevice;
if (typedSender != null)
{
// Always stop the device
typedSender.Stop();
// Get the new value
string newMonikerString = e.NewValue as string;
// Check if we have a valid moniker string
if (!string.IsNullOrEmpty(newMonikerString))
{
// Initialize device
typedSender.InitializeDeviceForMoniker(newMonikerString);
// Start
typedSender.Start();
}
}
}