在MahApps.Metro MessageDialog按钮中更改UI样式

时间:2015-10-27 06:58:21

标签: mahapps.metro

我的应用程序有自定义主题,我想更改MessageDialog生成的按钮的按钮样式(颜色,边框等等)以匹配我的应用程序主题。在XAML中有一种简单的方法吗?

1 个答案:

答案 0 :(得分:0)

如果您在app.xaml中设置应用程序主题,如下所示,标准的mahapps.metro样式通常可以很好地匹配应用程序(包括mahapps MessageDialog)。

的App.xaml

<ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <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" />
            <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/Red.xaml" />
            <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseLight.xaml" />
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>

示例按钮样式

   <Button Style="{DynamicResource AccentedSquareButtonStyle}" />
   <Button Style="{DynamicResource MetroCircleButtonStyle}"/>

如果您的代码部分

,您也可以更改样式
 <StackPanel>
        <StackPanel.Resources>
            <ResourceDictionary>
                <ResourceDictionary.MergedDictionaries>
                    <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/FlatButton.xaml" />
                </ResourceDictionary.MergedDictionaries>
            </ResourceDictionary>
        </StackPanel.Resources>
    </StackPanel>

您应该查看MahMappsmetro及其Github

希望这就是你所要求的。