找不到WPF资源

ime*_*kon 3 wpf systemcolors

如果我在XAML中使用以下内容,则会收到错误消息:

    <Style TargetType="TreeViewItem">
        <Style.Triggers>
            <DataTrigger Binding="{Binding Selected}" Value="True">
                <Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.HighlightColor}}"/>
            </DataTrigger>
        </Style.Triggers>
    </Style>
Run Code Online (Sandbox Code Playgroud)

错误是:

System.Windows.ResourceDictionary Warning: 9 : Resource not found; ResourceKey='#FF316AC5'
Run Code Online (Sandbox Code Playgroud)

Jul*_*ain 5

你的意思是HighlightColorKey,不是HighlightColor.该键用于,DynamicResource而颜色仅用于{x:Static}但不是动态的.