HandyOrg / HandyOrg/HandyControl
当Badge用于Listbox和Listview时发生的错误
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
背景,仿微信好友列表,需要在列表项头像嵌套个Badge用于标记未读消息数
<hc:Badge Value="{Binding Path=BadgeCount, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type local:ChatSessionItem}}}" Status="Text" Style="{StaticResource BadgeDanger}">
</hc:Badge>
当列表数导致项目绘制范围超出Listbox或ListView可视范围会爆出ControlTemplate无法找到Border
目前我的解决办法是吧Badge相关源码复制到项目中将BadgeBaseStyle中17-26行代码删除,就不再出现以上错误
Steps to reproduce the bug
1、创建个WPF项目
2、创建个UserControl,将Badge嵌套在Image上
3、WPF窗口创建个ListBox或ListView控件
4、引用UserControl并填至Listboxitem或Listviewitem中
5、使Listbox或listview列表内容溢出可视区域
6、bug重现
Expected behavior
No response
Screenshots
No response
NuGet package version
No response
IDE
Visual Studio 2022
Framework type
.Net 6.0
Windows version
Windows 11 (22000)
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 with the Badge control and its BadgeBaseStyle, then reproduce the issue in a WPF project using the provided ListBox/ListView steps and an Image child. Compare behavior when list items extend beyond the visible area, and consider the reported BadgeBaseStyle lines 17-26 as the key investigation point; done means the nested Badge renders without a ControlTemplate/Border error.
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
- 35/100