我有WPF
(MVVM
)个应用,我正在使用MahApps
,我有:
Client
项目(基本上是主要的WPF项目)Helpers
项目Styling
项目在Helpers项目中,我有Helper
类为我激发ShowMessageAsync
方法:
public static class ShowMessageBox
{
public static async Task Show(MetroWindow metroWindow, string titre, string errorMessage, string errorDetails, string errorHelpLink)
{
var mySettings = new MetroDialogSettings()
{
AffirmativeButtonText = "Ok",
NegativeButtonText = "Annuler",
ColorScheme = MetroDialogColorScheme.Accented,
AnimateShow = true,
AnimateHide = true
};
await metroWindow.ShowMessageAsync(titre, string.Format(errorMessage + " ! \n {0} ... \n {1}",
errorDetails, errorHelpLink), MessageDialogStyle.Affirmative, mySettings);
}
//...
在样式项目中,我在MahApps.xaml
文件中调用MahApps资源:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Colors.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/orange.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/baselight.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
我从App.Xaml
引用了这个:
<Application.Resources>
<ResourceDictionary>
<valueConverters:ContentLengthToInvertedBooleanConverter x:Key="ContentLengthToInvertedBooleanConverter" />
<valueConverters:ContentLengthToBooleanConverter x:Key="ContentLengthToBooleanConverter" />
<viewModels:ViewModelLocator x:Key="Locator" d:IsDataSource="True" />
<valueConverters:ListToIsEnabledConverter x:Key="ListToIsEnabledConverter" />
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/Styling;component/MahApps.xaml" />
<ResourceDictionary Source="pack://application:,,,/Styling;component/Styles.xaml" />
<ResourceDictionary Source="pack://application:,,,/Styling;component/Brushes.xaml" />
<ResourceDictionary Source="pack://application:,,,/Styling;component/Assets/Assets.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
当我触发MessageDialog
(在某个ViewModel中)时:
var mainWindow = (MetroWindow)Application.Current.MainWindow;
await ShowMessageBox.Show(mainWindow, "Ajout !",
"Marque Ajoutée avec succés !", String.Empty, String.Empty,
0);
这是我得到的:
我得到的只是正确跟随重音的小Ok
按钮,但没有白色背景,没有文字,没有其他任何东西。请注意,我在每个项目中都引用了MahApps.Metro,这有什么问题?我怎么能纠正这个?