开发者

Opening a new window in WPF withoug using .show()?

开发者 https://www.devze.com 2022-12-26 17:54 出处:网络
It seems to be possible in this project... After they use pd = new ProgressDialog();, the new window appears.

It seems to be possible in this project...

After they use pd = new ProgressDialog();, the new window appears.

Ho开发者_运维技巧w did they do that?


Let's define next instances first:

BackgroundWorker worker;
ProgressDialog pd;

then show a form through the ShowDialog() method in the click handler:

private void btnReportProgress_Click(object sender, RoutedEventArgs e)
{
    int maxRecords = 1000;
    pd = new ProgressDialog();
    // doing something more...
    pd.ShowDialog();
}

ProgressDialog.xaml.cs class could have additional properties:

public string ProgressText
public int ProgressValue


pd.ShowDialog() is the last line of the btnReportProgress_Click function. It shows modal dialog, which is closed when the worker thread is completed, see worker.RunWorkerCompleted event subscription.


Maybe they call this.Show() in the constructor of ProgressDialog class.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号