问题描述
我一直在尝试修改ShowMessageAsync对话框的样式(主要是按钮颜色),到目前为止我所做的一切都没有起作用。
我一直在尝试使用我创建的字典来修改样式,以便所有对话框都具有相同的样式。
为了修改ShowMessageAsync的肯定和否定按钮,我一直在尝试什么:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:metro="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
xmlns:Dialogs="clr-namespace:MahApps.Metro.Controls.Dialogs;assembly=MahApps.Metro"
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
xmlns:controls="http://metro.mahapps.com/winfx/xaml/controls">
<Style BasedOn="{StaticResource {x:Type Dialogs:BaseMetroDialog}}" TargetType="{x:Type Dialogs:MessageDialog}" x:Key="NewCustomMessageDialogStyle">
<!-- This is the only part that is working -->
<Setter Property="Background" Value="DimGray"/>
<!------------------------------------------->
<Style.Resources>
<Style x:Key="AccentedDialogSquareButton"
BasedOn="{StaticResource MahApps.Styles.Button.Square}"
TargetType="{x:Type ButtonBase}">
<Setter Property="Background" Value="DarkRed" />
<Style.Triggers>
<Trigger Property="IsPressed" Value="True">
<Setter Property="Background" Value="DarkRed" />
<Setter Property="Foreground" Value="DarkGreen" />
</Trigger>
</Style.Triggers>
</Style>
<Style x:Key="AccentedDialogHighlightedSquareButton"
BasedOn="{StaticResource MahApps.Styles.Button.Square.Highlight}"
TargetType="{x:Type ButtonBase}">
<Setter Property="controls:ControlsHelper.ContentCharacterCasing" Value="Normal" />
<Style.Triggers>
<Trigger Property="IsPressed" Value="True">
<Setter Property="Background" Value="DarkRed" />
<Setter Property="Foreground" Value="DarkGreen" />
</Trigger>
</Style.Triggers>
</Style>
<Style BasedOn="{StaticResource MahApps.Styles.Button.MetroSquare}" TargetType="{x:Type Button}">
<Setter Property="controls:ControlsHelper.ContentCharacterCasing" Value="Normal" />
<Style.Triggers>
<Trigger Property="IsPressed" Value="True">
<Setter Property="Background" Value="DarkRed" />
<Setter Property="Foreground" Value="DarkGreen" />
</Trigger>
</Style.Triggers>
</Style>
</Style.Resources>
</Style>
<Style TargetType="{x:Type Dialogs:MessageDialog}" BasedOn="{StaticResource NewCustomMessageDialogStyle}"/>
如果您需要调用ShowMessageAsync方法:
messageDialogResult = await this.instance.ShowMessageAsync(this,"some text","",MessageDialogStyle.AffirmativeAndNegative,new MetroDialogSettings()
{
AffirmativeButtonText = "ok",NegativeButtonText = "cancel",ColorScheme = MetroDialogColorScheme.Accented,AnimateShow = true,AnimateHide = true
});
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)