首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >地铁MahApps MessageBox主题

地铁MahApps MessageBox主题
EN

Stack Overflow用户
提问于 2016-04-26 16:44:54
回答 2查看 3.1K关注 0票数 1

也许有人可以告诉我如何将异步消息正确地实现到Metro窗口,使其具有应用程序当前的主题和重音?

从演示示例中提取的代码可以工作,但是主题和重音仍然是默认的:

代码语言:javascript
复制
private async void ClosingApp(object sender, System.ComponentModel.CancelEventArgs e)
    {
        e.Cancel = !_shutdown;
        if (_shutdown) return;
        var mySettings = new MetroDialogSettings()
        {
            AffirmativeButtonText = "Quit",
            NegativeButtonText = "Cancel",
            AnimateShow = true,
            AnimateHide = false
        };
        var result = await this.ShowMessageAsync("Quit application?",
            "Sure you want to quit application?",
            MessageDialogStyle.AffirmativeAndNegative, mySettings);

        _shutdown = result == MessageDialogResult.Affirmative;
        if (_shutdown)
            Application.Current.Shutdown();
    }

当我简单地改变主题:

代码语言:javascript
复制
 private void MenuItem_Click(object sender, RoutedEventArgs e)
    {
        // set the Red accent and dark theme only to the current window
        var theme = ThemeManager.GetAppTheme("BaseDark");
        var accent = ThemeManager.GetAccent("Red");
        ThemeManager.ChangeAppStyle(Application.Current, accent, theme);
    }

我得到默认的白色和蓝色MessageBox。我做错了什么?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2016-04-26 17:27:16

我试过你的代码了,它正在工作。我只在一个MenuItem_Click中转换了Button_Click,但这是不相关的。

我得到了黑色的背景和红色退出,如下图所示,在单击“设置”按钮后,iff I关闭了应用程序。

而不是最初的

我有一个标准的Window1.xaml,从

代码语言:javascript
复制
<Controls:MetroWindow x:Class="TestFrontend.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
        Closing="App_Closing"
    Title="Test" Height="600" Width="600"
    >

和App.xaml中的资源

代码语言:javascript
复制
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    StartupUri="Window1.xaml">
  <Application.Resources>
    <ResourceDictionary>
      <ResourceDictionary.MergedDictionaries>
        <!-- MahApps.Metro resource dictionaries. Make sure that all file names are Case Sensitive! -->
        <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
        <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
        <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Colors.xaml" />
        <!-- Accent and AppTheme setting -->
        <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/Blue.xaml" />
        <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseLight.xaml" />
      </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
  </Application.Resources>
票数 0
EN

Stack Overflow用户

发布于 2016-04-27 09:00:02

我只需要添加默认的资源字典

<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/Blue.xaml" /> <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseLight.xaml" />中的App.xaml

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/36870966

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档