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