ResourceDictionary样式错误:“类型必须派生自FrameworkElement或FrameworkContentElement

Sha*_*tin 3 wpf xaml resourcedictionary

GridViewColumnHeader继承FrameworkElement,但GridViewColumn不继承。这是否意味着我们无法在资源字典中对后者进行样式设置?

文字片段

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

    <Style TargetType="{x:Type GridViewColumn}">
    </Style>

    <Style TargetType="{x:Type GridViewColumnHeader}">
        <Setter Property="Background" Value="LightBlue"/>
    </Style>

</ResourceDictionary>
Run Code Online (Sandbox Code Playgroud)

带有错误消息的代码段

资源字典摘要

dev*_*hog 5

是的,这正是您所说的。GridViewColumn没有样式。它不是UiElement。但是GridViewColumnHeader是其中之一,它支持样式。