使用Material Design Toolkit,Mahapps Metro Window中的Flyouts无法正常工作

时间:2017-01-15 14:08:54

标签: wpf material-design mahapps.metro flyout

上下文:我使用Mahapps.Metro Flyouts和Material Design工具包。

问题:当Flyout打开时,它未按指定定位。例如,如果我将Flyout设置为Bottom的{​​{1}},则它会定位在垂直中心。

我已经设置了App.xaml以支持Mahapps和Material Design。我还对主题和重音进行了映射,以获得一致的体验。

我采用了MD WIKI中显示的配置。我有一个Metro Window,我的应用程序使用Mahapps和Material Design样式的各种控件 - 没有任何麻烦。只有弹出窗口无法正常工作。

为了解决问题,我将应用程序降至最低。此外,我从Material Design Mahapps演示应用程序中获取了示例弹出窗口 虽然演示应用程序运行完美,但它在我的应用程序环境中不起作用。

如果我将Mahapps-MD兼容性内容从App.xaml中删除,则弹出按钮正常工作,但当然没有MD主题。

App.xaml中:

Window

窗口(缩减为相关内容):

<Application x:Class="Frontend.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:local="clr-namespace:Frontend" 
             StartupUri="MainWindow.xaml" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             d1p1:Ignorable="d"
             xmlns:d1p1="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:UiLogic="clr-namespace:EPM.Frontend.Logic;assembly=Frontend.Logic">
    <Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary>
                    <UiLogic:ViewModelLocator x:Key="Locator" d:IsDataSource="True" />
                </ResourceDictionary>

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

                <!-- Material Design -->
                <ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Light.xaml" />
                <ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Defaults.xaml" />
                <ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Primary/MaterialDesignColor.DeepPurple.xaml" />
                <ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Accent/MaterialDesignColor.Lime.xaml" />

                <!-- Material Design: MahApps Compatibility -->
                <ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.MahApps;component/Themes/MaterialDesignTheme.MahApps.Fonts.xaml" />
                <ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.MahApps;component/Themes/MaterialDesignTheme.MahApps.Defaults.xaml" />
                <!--<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.MahApps;component/Themes/MaterialDesignTheme.MahApps.Flyout.xaml" />-->

                <ResourceDictionary Source="/Resources/Icons.xaml" />
                <ResourceDictionary Source="Themes/Colors.xaml"/>

            </ResourceDictionary.MergedDictionaries>

            <!-- MahApps Brushes -->
            <SolidColorBrush x:Key="HighlightBrush" Color="{DynamicResource Primary700}"/>
            <SolidColorBrush x:Key="AccentColorBrush" Color="{DynamicResource Primary500}"/>
            <SolidColorBrush x:Key="AccentColorBrush2" Color="{DynamicResource Primary400}"/>
            <SolidColorBrush x:Key="AccentColorBrush3" Color="{DynamicResource Primary300}"/>
            <SolidColorBrush x:Key="AccentColorBrush4" Color="{DynamicResource Primary200}"/>
            <SolidColorBrush x:Key="WindowTitleColorBrush" Color="{DynamicResource Primary700}"/>
            <SolidColorBrush x:Key="AccentSelectedColorBrush" Color="{DynamicResource Primary500Foreground}"/>
            <LinearGradientBrush x:Key="ProgressBrush" EndPoint="0.001,0.5" StartPoint="1.002,0.5">
                <GradientStop Color="{DynamicResource Primary700}" Offset="0"/>
                <GradientStop Color="{DynamicResource Primary300}" Offset="1"/>
            </LinearGradientBrush>
            <SolidColorBrush x:Key="CheckmarkFill" Color="{DynamicResource Primary500}"/>
            <SolidColorBrush x:Key="RightArrowFill" Color="{DynamicResource Primary500}"/>
            <SolidColorBrush x:Key="IdealForegroundColorBrush" Color="{DynamicResource Primary500Foreground}"/>
            <SolidColorBrush x:Key="IdealForegroundDisabledBrush" Color="{DynamicResource Primary500}" Opacity="0.4"/>
        </ResourceDictionary>
    </Application.Resources>
</Application>

我使用的套餐:

<Controls:MetroWindow x:Class="Frontend.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:EPM.Frontend"
        xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
        xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
        xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks"
        mc:Ignorable="d"
        DataContext="{Binding Main, Mode=OneWay, Source={StaticResource Locator}}"
        Title="electronic platform manager" Width="732" Height="452"
        Background="{DynamicResource MaterialDesignPaper}"
        BorderThickness="1"
        BorderBrush="{DynamicResource AccentColorBrush}"
        EnableDWMDropShadow="True">

   <Controls:MetroWindow.Flyouts>
        <Controls:FlyoutsControl x:Name="flyoutsControl">
            <Controls:Flyout x:Name="LeftFlyout" Position="Bottom" Header="Settings" materialDesign:FlyoutAssist.HeaderColorMode="Accent" IsOpen="True" Height="80">
                <local:FlyoutContent />
            </Controls:Flyout>
        </Controls:FlyoutsControl>
    </Controls:MetroWindow.Flyouts>

</Controls:MetroWindow>

输出:

enter image description here

尝试了几个小时后,我仍然不知道问题是什么。任何提示都受到高度赞赏。

祝你好运, 马库斯

0 个答案:

没有答案