[英]MahApps and Property Grid
首先,非常感谢MahApps。 多么酷的项目!
我有一个用WPF编写的现有应用程序,我已经应用了MahApps库。 我用过这个教程:
http://mahapps.com/guides/quick-start.html
然而,对Property Grid(Xceed)的影响微乎其微。
我其他窗口中的组合框如下所示:
属性网格组合框仍然看起来像这样(丑陋!):
但是,单击组合框会显示项目的正确MahApp样式。 只有组合盒本身(封闭)不平坦。
我对WPF的了解是基本的。 我将从哪里开始尝试修复此问题? 我是否需要手动覆盖Property Grid中的组合框模板?
在MainWindow.xaml中使用
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"
>
在MainWindow.xaml.cs继承
MetroWindow
namespace AppWin
{
public partial class MainWindow : MetroWindow
{
...
添加App.xaml以下设置
<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>
也许你的其他组合框看起来很难看,因为找不到MahApps的资源?
将您正在使用的mahapp资源放在App.xaml文件的资源字典中,以便所有窗口都可以访问它。 (而不是只在一个窗口中将它们放在资源字典中,即mainwindow.xaml)
App.xaml中:
<Application... >
<Application.Resources>
<ResourceDictionary>
<!-- My other resources -->
<!-- ... -->
<!-- MahApps resources -->
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Colors.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.AnimatedSingleRowTabControl.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseDark.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
属性网格覆盖了MahApps的样式。 您必须为您的属性创建一个自己的PropertyEditor。 PropertyEditor会覆盖属性网格的样式。
我知道这很多工作,但它是获得MahApps外观的唯一方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.