public SelectFGWindow(Window owner) { this.Owner = owner; InitializeComponent(); displayMessage("Select Frame-Grabber"); xamlButtonOK.IsEnabled = false; DeviceIdentity[] dis = FPScanner.GetDevices(); xamlListBoxFG.ItemsSource = dis; }
private async void NewMethod_InitializeComponent() { InitializeComponent(); Control.CheckForIllegalCrossThreadCalls = false; displayMessage("Select Frame-Grabber"); xamlButtonOK.Enabled = false; DeviceIdentity[] dis = FPScanner.GetDevices(); xamlListBoxFG.DataSource = dis; xamlListBoxFG.SelectedIndex = 0; if (xamlListBoxFG.Items.Count > 1) { //Show(); DeviceIdentity selectedDI = (DeviceIdentity)xamlListBoxFG.SelectedItem; //Get selected Frame-Grabber this.SelectedDeviceIdentity = selectedDI; xamlButtonOK.Enabled = true; rDialogResult = true; } else if (xamlListBoxFG.Items.Count == 1) { Hide(); ////////////////////////////////////////////////////////////// //Dont alter this codes below, it will lead toerror int rr = await Task.Run(() => { DeviceIdentity selectedDI = (DeviceIdentity)xamlListBoxFG.SelectedItem; //Get selected Frame-Grabber this.SelectedDeviceIdentity = selectedDI; xamlButtonOK.Visible = false; rDialogResult = true; return(1); }); this.Close(); ////////////////////////////////////////////////////////////// } }