我如何加载 WPF 的主窗体,以便在窗体处于公寓状态时一个单独的线程从数据库中获取数据?(可拖动/可移动)
我知道这可以通过从您的主窗体中打开一个新窗口来实现,如下所示:
Private Sub openOrderWindow()
Dim OrderWindow As Orders = New Orders
OrderWindow.ShowDialog()
End Sub
Private Sub ButtonImport_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles ButtonImport.Click
Dim iThread As System.Threading.Thread = New System.Threading.Thread(AddressOf openOrderWindow)
iThread.SetApartmentState(System.Threading.ApartmentState.STA)
iThread.Start()
ListViewOrderDetail.Focus()
' Me.Close()
End Sub
因为我使用'ShowDialog'
但是在主窗口上我不能调用 ShowDialog
我试过的:
Private Sub AccessDBFilling()
ListViewDataGrid.ItemsSource = Nothing
accessdblist = Nothing
accessdblist = accessdb.GetFromAccess()
ListViewDataGrid.ItemsSource = accessdblist
End Sub
Private Sub refresh()
ListViewDataGrid.Dispatcher.Invoke(New Action(AddressOf AccessDBFilling))
End Sub
Private Sub Window_Loaded(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles MyBase.Loaded
iThread = New System.Threading.Thread(AddressOf refresh)
iThread.SetApartmentState(System.Threading.ApartmentState.STA)
iThread.Start()
End Sub
我试过把MyBase.ShowDialog()
和.Show()
.9000+ 其他东西
我使用单独的线程从数据库加载的唯一好处是我可以立即看到屏幕(相反它是一个透明框,直到它加载)但我不能移动它或最小化它
有没有办法让它在加载时移动?