2

WPF 4への回答に関するコメントに関連して、別の質問をする: DataGridColumnHeaderに何が起こったのですか?

UserControl では DataGridHeaderBorder を使用でき、ResourceDictionary ではスタンドアロンで使用できますが、Style の Template のセッターでは使用できないようです。

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    >

    <!-- Works -->
    <DataTemplate x:Key="yomama">
        <DataGridColumnHeader />
    </DataTemplate>

    <!-- Compile Error: error MC3074: The tag 'DataGridHeaderBorder' does not exist in XML namespace 'http://schemas.microsoft.com/winfx/2006/xaml/presentation'. -->
    <Style x:Key="{x:Type DataGridRowHeader}"
        TargetType="{x:Type DataGridRowHeader}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type DataGridRowHeader}">
                    <Grid>
                        <DataGridHeaderBorder></DataGridHeaderBorder>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

プロジェクトで WPFToolkit を参照していなくても、xmlns:dg="http://schemas.microsoft.com/wpf/2008/toolkit" を使用すれば動作させることができます。.NET4 に設定され、PresentationFramework v4 を参照していることを確認しました。

dg: ハックの削除にご協力いただきありがとうございます。

4

3 に答える 3

9

試す:

xmlns:Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero"
于 2011-01-24T03:56:20.043 に答える
2

これを試すこともできます。この場合、ヘッダーの前景を変更します。

<Style x:Key="Consulta_Grilla_HeaderStyle" 
       TargetType="{x:Type DataGridColumnHeader}">
    <Style.Resources>
        <Style TargetType="{x:Type Grid}" >
            <Setter Property="TextBlock.Foreground" Value="Yellow"/>      
        </Style>
    </Style.Resources>
</Style>
于 2011-12-14T22:45:03.183 に答える
-1

プロジェクトの参照に PresentationFramework.Aero.dll を追加します。

于 2015-09-16T09:00:16.577 に答える