使用MahApps Metro主题VS2013

时间:2014-03-08 05:18:24

标签: c# xaml mahapps.metro

我正在尝试执行“使用入门”说明:http://mahapps.com/MahApps.Metro/guides/quick-start.html

我已经获得了最新的预发行版(也尝试过稳定版),我没有得到指南制作的同一个窗口。我得到一个透明的窗口和标题栏,所以它看起来像一个浮动的标题栏,并最小化,最大化和关闭按钮。

当我添加样式时,我得到一个带有蓝色标题栏的白色背景,但没有阴影。我在这里做错了还是有其他人经历过这个?

感谢。

编辑:这是XAML

主窗口

<Controls:MetroWindow x:Class="Metro.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro" 
    Title="MainWindow" Height="900" Width="1600">
</Controls:MetroWindow>

App.xaml

<Application x:Class="Metro.App"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         StartupUri="MainWindow.xaml">
<Application.Resources>
    <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/Blue.xaml" />
            <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseLight.xaml" />
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
</Application.Resources>

正如我所提到的,我遵循了入门指示,我复制并粘贴了完全相同的代码,并得到了不同的结果。

1 个答案:

答案 0 :(得分:45)

修改 quick start指南和MetroWindow help现已更新(2014年9月4日)。

快速入门的屏幕/示例尚未完全更新。

你可以有一个边框

<controls:MetroWindow x:Class="MahApps.Metro.Simple.Demo.MainWindow"
                      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                      xmlns:controls="http://metro.mahapps.com/winfx/xaml/controls"
                      Title="MainWindow"
                      Height="200"
                      Width="600"

                      BorderBrush="{DynamicResource AccentColorBrush}"
                      BorderThickness="1"

                      WindowStartupLocation="CenterScreen">

</controls:MetroWindow>

enter image description here

或发光边框

<controls:MetroWindow x:Class="MahApps.Metro.Simple.Demo.MainWindow"
                      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                      xmlns:controls="http://metro.mahapps.com/winfx/xaml/controls"
                      Title="MainWindow"
                      Height="200"
                      Width="600"

                      GlowBrush="{DynamicResource AccentColorBrush}"

                      WindowStartupLocation="CenterScreen">

</controls:MetroWindow>

enter image description here

或投影

<controls:MetroWindow x:Class="MahApps.Metro.Simple.Demo.MainWindow"
                      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                      xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
                      xmlns:controls="http://metro.mahapps.com/winfx/xaml/controls"
                      xmlns:behaviours="http://metro.mahapps.com/winfx/xaml/shared"
                      Title="MainWindow"
                      Height="200"
                      Width="600"
                      ResizeMode="CanResizeWithGrip"
                      WindowTransitionsEnabled="False"
                      WindowStartupLocation="CenterScreen">

  <i:Interaction.Behaviors>
    <behaviours:BorderlessWindowBehavior AllowsTransparency="False"
                                         EnableDWMDropShadow="True" />
    <behaviours:WindowsSettingBehaviour />
    <behaviours:GlowWindowBehavior />
  </i:Interaction.Behaviors>

</controls:MetroWindow>

<强>更新

EnableDWMDropShadow已在版本0.13 alpha(最新版本)中移至MetroWindow

<controls:MetroWindow x:Class="MahApps.Metro.Simple.Demo.MainWindow"
                      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                      xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
                      xmlns:controls="http://metro.mahapps.com/winfx/xaml/controls"
                      xmlns:behaviours="http://metro.mahapps.com/winfx/xaml/shared"
                      Title="MainWindow"
                      Height="200"
                      Width="600"

                      EnableDWMDropShadow="True"
                      ResizeMode="CanResizeWithGrip"

                      WindowTransitionsEnabled="False"
                      WindowStartupLocation="CenterScreen">

</controls:MetroWindow>

enter image description here

希望有所帮助