private void btnOk_Click(object sender, RoutedEventArgs e) { Result = new PortConfig(); Result.PortA = IsComAValid() ? txtPortAName.Text : "-"; DialogResult = true; }