簡體   English   中英

不完整的mahapps.metro對話框

[英]incomplete mahapps.metro dialogs

我使用帶有自定義重音的mahapps.metro。 當應用程序啟動時,我正在通過代碼更改口音。 從那時起,這些對話框就無法正確顯示。

我不知道出了什么問題。 我的App.xaml是

<Application.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
            <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.AnimatedTabControl.xaml" />
            <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/Indigo.xaml" />
            <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseLight.xaml" />
            <ResourceDictionary Source="Assets/ButtonStyles.xaml"/>
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
</Application.Resources>

在代碼中

Uri objUri = new Uri("Assets/CustomAccent.xaml", UriKind.Relative);
Accent acc = new Accent("CustomAccent", objUri);
ThemeManager.ChangeTheme(App.Current, acc, Theme.Light);

用我自定義的口音,我只是在改變顏色,沒有別的。 任何想法?

要使用自定義口音,必須先將其添加到ThemeManagerMahApps.Metro v1.0.0 )。

public partial class App : Application
{
    protected override void OnStartup(StartupEventArgs e)
    {
        // add custom accent and theme resource dictionaries
        ThemeManager.AddAccent("CustomAccent1", new Uri("pack://application:,,,/MahAppsMetroThemesSample;component/CustomAccents/CustomAccent1.xaml"));

        // get the theme from the current application
        var theme = ThemeManager.DetectAppStyle(Application.Current);

        // now use the custom accent
        ThemeManager.ChangeAppStyle(Application.Current,
                                    ThemeManager.GetAccent("CustomAccent1"),
                                    theme.Item1);

        base.OnStartup(e);
    }
}

希望這可以幫助。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM