Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF resource not found

If I use the following in XAML I get an error:

    <Style TargetType="TreeViewItem">
        <Style.Triggers>
            <DataTrigger Binding="{Binding Selected}" Value="True">
                <Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.HighlightColor}}"/>
            </DataTrigger>
        </Style.Triggers>
    </Style>

The error is:

System.Windows.ResourceDictionary Warning: 9 : Resource not found; ResourceKey='#FF316AC5'
like image 235
imekon Avatar asked Apr 14 '26 13:04

imekon


1 Answers

You meant HighlightColorKey, not HighlightColor. The key is used with DynamicResource whereas the color is used only with {x:Static} but won't be dynamic.

like image 123
Julien Lebosquain Avatar answered Apr 16 '26 12:04

Julien Lebosquain



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!