Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在WPF应用程序中查找SQL Server_Wpf - Fatal编程技术网

在WPF应用程序中查找SQL Server

在WPF应用程序中查找SQL Server,wpf,Wpf,我正在将旧应用程序从windows窗体移动到WPF,在此方法中遇到带下划线的行错误。有人能帮我解决这些问题吗;悬挂式布局;简历布局。我的老办法是: private void FindDataBases() { string tempDBName = comboBoxDataBases.Text; // ((FrameworkElement) this).Cursor = Cursors.WaitCursor; ((FrameworkElement)this).Cursor =

我正在将旧应用程序从windows窗体移动到WPF,在此方法中遇到带下划线的行错误。有人能帮我解决这些问题吗;悬挂式布局;简历布局。我的老办法是:

private void FindDataBases()
{
   string tempDBName = comboBoxDataBases.Text;

   // ((FrameworkElement) this).Cursor = Cursors.WaitCursor;
   ((FrameworkElement)this).Cursor = Cursors.Wait;

   Application.DoEvents();

   SuspendLayout();

   DataSet dataBases = GetDatabases();

   ((FrameworkElement) this).Cursor = Cursors.Default;
   Application.DoEvents();

   if ((dataBases != null) && (dataBases.Tables[0].Rows.Count > 0))
   {
      comboBoxDataBases.DisplayMember = "DbName";
      comboBoxDataBases.DataSource = dataBases.Tables[0];

      if (comboBoxDataBases.FindStringExact(tempDBName) > 0)
      {
         comboBoxDataBases.SelectedIndex = comboBoxDataBases.FindStringExact(tempDBName);
      }
   }
   else
   {
      comboBoxDataBases.DataSource = null;
   }

   ResumeLayout();

   // this.comboBoxDataBases.Focus();
}

在枚举数据库时,我会尽量不阻止应用程序。让一个背景线程来做这项工作怎么样?可能是一个
后台工作人员
?后台线程启动时锁定UI,完成后解锁UI。好了,WPF中已经没有了
Application.DoEvents()

您能告诉我们问题出在哪里吗?错误消息是什么?正如我所说的DoEvents;悬挂式布局;简历布局是在WPFI中不再起作用的东西,只需要在WPF中像我在posted方法中那样做。