LoginSignup
34
24

More than 1 year has passed since last update.

いい感じのMessageBox for WPF

Posted at

WPF用のメッセージボックスです。

特徴

  • 追加メッセージをエクスパンダーに配置して表示
  • メッセージの色を変更
  • 影のエフェクトを表示可
  • コンテキストメニューから、メッセージと追加メッセージをコピー可
  • オーナーのウインドウを指定して薄暗くする。

スクリーンショット

2022-02-06_15h48_07.png
2022-02-06_15h48_45.png
2022-02-06_15h48_52.png
2022-02-06_15h49_11.png
2022-02-06_15h51_21.png
2022-02-06_15h52_16.png
2022-02-06_16h04_17.png

使い方

MessageEx.ShowInformationDialog("Message");
MessageEx.ShowInformationDialog("Message", "AppendedMessage");

詳しくは、コードを参照して下さい。

ダウンロード

アイコン

アイコンは、Fluent UI System Iconsを利用しました。

日本語化

public string OKCaption { get; set; } = "OK";
public string YesCaption { get; set; } = "Yes";
public string NoCaption { get; set; } = "No";
public string CancelCaption { get; set; } = "Cancel";

の部分で、OK以外を、「はい」「いいえ」「キャンセル」にして下さい。

例外発生の可能性

if (owner is not null) this.Owner = owner;

のownerはWindowです。Windowが表示されていない時などの、ある条件下で、例外になる可能性があります。

参考

ModernDialog.ShowMessage Error: "Cannot set Owner property to a Window that has not been shown previously."

機能作成方針

WPF用のメッセージボックスは、多く作成されています。ただ、次の要件に見合う物がなかったので、作成しました。

  • メッセージボックスが表示されたと、認識しやすいこと。
  • メッセージの追加情報は、隠しておいて、知りたい時は表示する。→ 余分な情報があると分かりにくくなる。しかし、必要になる時があるので、その時は、表示したい。
  • メッセージはコピーできる。

備考

この記事の履歴

2022-02-06 この記事を公開。Ver 1.0を公開。

34
24
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
34
24