我正在编写一个wpf应用程序,它在单击按钮时从excel表中提取数据并加载另一个存在数据网格的窗口,显示结果。
现在加载第二个窗口需要10-12秒,在此期间我的应用程序冻结。现在我想要的是显示一个旋转的小圆形带状按钮,并显示“请稍候”文本。这将显示在第一个窗口的中央,第一个窗口的其他内容将变暗。
加载第二个窗口后,第一个窗口关闭。 请告诉我怎么做。
答案 0 :(得分:1)
问题得到解决。非常感谢你的帮助。以下是我使用的代码。
namespace ScoreX
{
public partial class Score : Window
{
Applications ap;
public Score()
{
InitializeComponent();
}
private void Window_Loaded_1(object sender, RoutedEventArgs e)
{
//cb is Circular progress bar
cbProgress.Visibility = Visibility.Hidden;
//Some codes
}
private void btnProceed_Click(object sender, RoutedEventArgs e)
{
//Some lines of Codes
Thread t1 = new Thread(new ThreadStart(CalculateData));
t1.SetApartmentState(ApartmentState.STA);
t1.Start();
cbProgress.Visibility = Visibility.Visible;
}
private void CalculateData()
{
//Some codes
Dispatcher.Invoke(DispatcherPriority.Normal, (Action)delegate()
{
ap = new Applications();
this.Close();
ap.ShowDialog();
}
);
}