MahApps Metro DialogBox不显示文本和背景

时间:2015-10-26 11:08:54

标签: c# wpf xaml mvvm mahapps.metro

我有WPFMVVM)个应用,我正在使用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);

这是我得到的:

enter image description here

我得到的只是正确跟随重音的小Ok按钮,但没有白色背景,没有文字,没有其他任何东西。请注意,我在每个项目中都引用了MahApps.Metro,这有什么问题?我怎么能纠正这个?

0 个答案:

没有答案