public MainWindow() { InitializeComponent(); //Display the window CameraSelector camera_selector = new CameraSelector(); camera_selector.ShowDialog(); //Get the result of the dialog CameraSelectorViewModel selector_result = CameraSelectorViewModel.GetInstance(); if (selector_result.ResultOK) { //Start playing from the webcam string moniker_string = selector_result.AvailableCameras[selector_result.SelectedCameraIndex].ModelCamera.CameraInfo.MonikerString; var camera = new VideoCaptureDevice(moniker_string); CameraVideoSourcePlayer.VideoSource = camera; CameraVideoSourcePlayer.Start(); //Set the data context of the main window DataContext = new MainWindowViewModel(moniker_string); } else { this.Close(); } }
public CameraSelector() { InitializeComponent(); //Set the data context this.DataContext = CameraSelectorViewModel.GetInstance(); }