mahapps中从右到左的对话框

时间:2018-02-07 17:15:05

标签: wpf dialog right-to-left mahapps.metro

我正在使用Mahapps,metro toolkit来创建一个WPF应用程序。我想显示一个从右到左的对话框。

await this.ShowMessageAsync("This is the title", "Some message");

我使用上面的代码来创建对话框,但它是从左到右。

2 个答案:

答案 0 :(得分:0)

这是如何在MessageBox中对齐。您应该使用MahApps.Metro检查是否有类似的方法来执行此操作:

MessageBox.Show("hi", "hey", MessageBoxButton.OK, MessageBoxImage.Information, MessageBoxResult.OK, MessageBoxOptions.RightAlign);

参数依次为:

  • 消息
  • 标题
  • 按钮类型
  • 显示图标
  • 用户点击
  • 返回的按钮类型
  • 显示选项(这是您要查找的参数)

这将创建以下对话框:

enter image description here

答案 1 :(得分:0)

我找到了解决方案。只需将此样式添加到app.xaml

即可

<Style TargetType="{x:Type Dialog:MessageDialog}" BasedOn="{StaticResource {x:Type Dialog:BaseMetroDialog}}"> <Setter Property="FlowDirection" Value="RightToLeft" /> </Style>

这是我的app.xaml文件

<Application xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:local="clr-namespace:RandomQuestions"
         xmlns:Dialogs="clr-namespace:MahApps.Metro.Controls.Dialogs;assembly=MahApps.Metro"
         xmlns:controls="http://metro.mahapps.com/winfx/xaml/controls"
         StartupUri="MainWindow.xaml">
<Application.Resources>
    <ResourceDictionary >
        <Style TargetType="{x:Type Dialogs:MessageDialog}" BasedOn="{StaticResource {x:Type Dialogs:BaseMetroDialog}}">
            <Setter Property="FlowDirection" Value="RightToLeft" />
        </Style>
        <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/Amber.xaml" />
            <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseLight.xaml" />

        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
</Application.Resources>