簡體   English   中英

MahApps和Property Grid

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM