首先,非常感谢 MahApps。多么酷的项目!
我有一个用 WPF 编写的应用程序,我已经应用了 MahApps 库。我使用了本教程:
http://mahapps.com/guides/quick-start.html
然而,对 Property Grid (Xceed) 的影响很小。
我的其他窗口中的组合框如下所示:
属性网格组合框看起来仍然像这样(丑陋!):
但是,单击组合框会显示项目的正确 MahApps 样式。只有组合框本身(闭合的)不是平面的。
我对 WPF 的了解很基础。我应该从哪里开始尝试解决这个问题?我是否需要手动覆盖属性网格中的组合框模板?
最佳答案
in MainWindow.xaml use
Controls:MetroWindow
<Controls:MetroWindow x:Name="MainApp" x:Class="AppWin.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"
MinHeight="700"
MinWidth="1024"
>
in MainWindow.xaml.cs inheritance
MetroWindow
namespace AppWin
{
public partial class MainWindow : MetroWindow
{
...
add App.xaml following settings
<Application x:Class="AppWin.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:AppWin"
StartupUri="MainWindow.xaml">
<Application.Resources>
<ResourceDictionary>
<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" />
/*--change template color for example green.xaml--*/
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/red.xaml" />
/*--change template style for example BaseDark.xaml--*/
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseLight.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
关于c# - MahApps 和属性网格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46023054/