HandyControl icon indicating copy to clipboard operation
HandyControl copied to clipboard

当Badge用于Listbox和Listview时发生的错误

Open inows opened this issue 2 years ago • 2 comments

Describe the bug

背景,仿微信好友列表,需要在列表项头像嵌套个Badge用于标记未读消息数 <hc:Badge Value="{Binding Path=BadgeCount, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type local:ChatSessionItem}}}" Status="Text" Style="{StaticResource BadgeDanger}"> <Image Width="48" Height="48"/> </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

inows avatar Oct 04 '22 14:10 inows

更新 应当与此修复操作关系不大Badge相关源码复制到项目中将BadgeBaseStyle中17-26行代码删除,就不再出现以上错误

今日直接将badge相关源码复制到项目中,只是修改了Namespace与项目同步,并未删除上述17-26行代码,也不再报错

inows avatar Oct 05 '22 02:10 inows

我是通过 额外的方式解决的,我先用一个属性让它显示出来, Application.Current.Dispatcher.Invoke UI等在刷新后,在执行对value的变化

brushli avatar Sep 14 '24 02:09 brushli