MaterialDesignInXAML / MaterialDesignInXAML/MaterialDesignInXamlToolkit

Window becomes inactive after DialogHost.Show()

オープン
#3,497 コメント 12 件 リアクション 0 件 担当者 1 名 GitHub で見る

@MichelMichels がすでに取り組んでいます。

2024年3月31日 から。

bug dialoghost
主要言語
C#
スター
16.3k
フォーク
3.5k
平均マージ
1日 22時間
マージ済み PR(30日)
8

説明

### Bug explanation

I'm trying to make a preloader using DialogHost (I need to display a loading indicator and lock the application while the data is being loaded)

However, when I call DialogHost.Show(), the application window loses focus

**5.0.1-ci571:**

https://github.com/MaterialDesignInXAML/MaterialDesignInXamlToolkit/assets/12599641/870a9dc8-6a78-467a-923e-92513d43876c

if you click on a dialog, the window will become active again along with the dialog.
so they are not mutually exclusive

In my past project I used version 4.6.1 and the window did not lose focus when DialogHost was opened

I tried different versions in the current project:
- **4.10.0-ci317** everything works perfectly
- **5.0.0-ci321** this bug appears

**4.10.0-ci317:**

https://github.com/MaterialDesignInXAML/MaterialDesignInXamlToolkit/assets/12599641/47933a28-e0f8-4cf1-8cea-f3b8a798802f

How can this be fixed without downgrading to an older version?

My code:

**PreloaderDialog**
```csharp

```

**MainWindow**
```csharp


...

```

**Method to show preloader**
```csharp
public static async Task DoWithPreloader(Action action, string host = DIALOG_ROOT) {
var dialog = new PreloaderDialog();

if (DialogHost.IsDialogOpen(host)) {
try {
DialogHost.Close(host);
} catch (Exception) {
// ignored
}
}

await DialogHost.Show(dialog, host, new DialogOpenedEventHandler((_, args) => {
action();
try {
if (!args.Session.IsEnded) {
args.Session.Close(false);
}
} catch (Exception) {
// ignored
}
}));
}
```

**Calling code**
```csharp
DialogUtils.DoWithPreloader(() => {
// some time-consuming code
});
```

### Version

5.0.1-ci571

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。