HandyOrg / HandyOrg/HandyControl
HighlightTextBlock的HighlightBrush不能响应DataTrigger
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 7.2k
- Forks
- 1.2k
- PR merge metrics
- No merged PRs in 30d
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
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
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.
Assessment
- Tech stack
- csharp
- Domain
- desktop
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100