像 Excel 一样在 Wpf itemscontrol 中拖动选择
我希望在 Wpf 项目控件中创建一个选择矩形,就像在 MS Excel 中一样。我查看了装饰器和装饰器,但没有得到什么帮助。我需要使用鼠标选择的单元格周围的粗边框(检查 screenShot)
I am looking to make a selection rectangle in Wpf items control just as in MS Excel.I have looked at decorators and adoners but got little help.I need the thick border around the cells that i select using mouse(check screenShot)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我为您提供了一个解决方案,该解决方案似乎只需要一个附加属性就可以很好地工作,以便您附加到项目控件(例如列表框)。
该代码仅通过检查索引是否连续来猜测所选项目是否连续。比如说一个带有一些行数的统一网格是行不通的,但这应该可以帮助你开始。
XAML 中的用法:
I have a solution for you, that seems to work fairly well with just an attached property for you to attach to an items control such as a listbox.
The code makes guesses as to whether or not selected items are contiguous by just checking that they are contiguous by index. With say a uniformgrid with some row count that won't work, but this should get you started.
Usage in XAML: