2011-04-22 83 views
3

可能重複:
WPF MessageBox window style有誰知道如何讓WPF MessageBox看起來更好(如Windows窗體equivelant)?

出於某種原因,附帶WPF的MessageBox已禁用視覺樣式,我無法找到一個方法來turne他們,在Windows窗體它只是在程序開始時調用Application.EnableVisualStyles()

要得到什麼,我談論的想法,這裏有兩個例子:

System.Windows.Forms.Application.EnableVisualStyles(); 
System.Windows.Forms.MessageBox.Show(
    "Windows Forms Dialog", 
    "Message Box Test", 
    System.Windows.Forms.MessageBoxButtons.OK, 
    System.Windows.Forms.MessageBoxIcon.Asterisk); 

Windows Forms MessageBox

System.Windows.MessageBox.Show(
    "WPF Dialog", 
    "Message Box Test", 
    System.Windows.MessageBoxButton.OK, 
    System.Windows.MessageBoxImage.Asterisk); 

WPF MessageBox

調用System.Windows.Forms.Application.EnableVisualStyles()爲WPF沒有影響。

Extended WPF Toolkit有一個很好的可實現的實現,但我正在尋找一種方法來創建消息框,以匹配用戶正在運行的操作系統。如果你想在每個操作系統上使用相同的風格,EWPFT的實現非常棒。

+0

我必須道歉,沒錯,這是一個重複,不知道爲什麼我沒有在搜索結果中看到它。 – 2011-04-22 19:34:30

+0

沒問題。我在自己面前遇到了這個問題,所以我知道要搜索「wpf messagebox manifest」。 – 2011-04-22 19:36:54

回答

3

不要使用的MessageBox了,P/Invoke的TaskDialogIndirect代替 - 它看起來比這兩個更好的,並且有更多的選擇(例如,具有任意的按鈕上的文字)

+0

感謝Paul,看起來像一個可行的解決方案,以提供額外的功能。 – 2011-04-22 19:35:59

+0

當然,這對xp – 2011-04-22 20:16:15

+1

@David停止使用XP失敗。請好嗎? – 2011-04-22 20:20:18

相關問題