Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

HighlightTextBlock的HighlightBrush不能响应DataTrigger

Open
#1,780 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
55/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
csharp
Domain
desktop

Research direction

Start at the HighlightTextBlock control and reproduce the provided .NET 6/WPF XAML example, comparing the working Foreground DataTrigger with the HighlightBrush and HighlightTextBrush setters. Trace how these properties are declared and applied, then verify that a DataTrigger changes the highlight brushes instead of retaining the explicitly set values.

Written by the indexing model from the issue text.

Description

Describe the bug

使用HighlightTextBlock时发现,即使设置了DataTrigger,HighlightBrush和HighlightTextBrush两个属性依然会使用默认值。

Steps to reproduce the bug
<hc:HighlightTextBlock SourceText="{Binding Header}" QueriesText="{Binding SearchText}" IsEnabled="False"
                        HighlightBrush="{DynamicResource DarkPrimaryBrush}" HighlightTextBrush="{DynamicResource TextIconBrush}">
    <hc:HighlightTextBlock.Style>
        <Style TargetType="hc:HighlightTextBlock">
            <Style.Triggers>
                <DataTrigger Binding="{Binding IsEnabled, RelativeSource={RelativeSource Self}}" Value="False">
                    <Setter Property="Foreground" Value="{DynamicResource SecondaryTextBrush}"/>
                    <Setter Property="HighlightBrush" Value="{DynamicResource Gray5Brush}"/>
                </DataTrigger>
            </Style.Triggers>
        </Style>
    </hc:HighlightTextBlock.Style>
</hc:HighlightTextBlock>

上面的例子中,IsEnabled==False时,DataTrigger设置的Foreground生效(使用了SecondaryTextBrush),但HighlightBrush没有变化(依然使用DarkPrimaryBrush)

Expected behavior

No response

Screenshots

No response

NuGet package version

HandyControl 3.5.1

IDE

Visual Studio 2022

Framework type

.Net 6.0

Windows version

No response

Additional context

No response

Dominant language
C#
Stars
7.2k
Forks
1.2k
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from HandyOrg/HandyControl

All issues in HandyOrg/HandyControl

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.