mahapps 中从右到左的对话框

right to left dialog in mahapps

我正在使用 Mahapps,metro 工具包创建 WPF application.I 想要显示从右到左的对话框。

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

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

这是在 MessageBox 中右对齐的方法。您应该检查是否有类似的方法可以使用 MahApps.Metro:

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

参数依次为:

  • 留言
  • 标题
  • 按钮类型
  • 显示的图标
  • 用户点击返回的按钮类型
  • 显示选项(这是你要找的参数)

这将创建以下对话框:

我找到 solution.just 将此样式添加到 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>