当前位置:网站首页>WPF效果第一百九十一篇之框选ListBox
WPF效果第一百九十一篇之框选ListBox
2022-07-06 03:39:00 【dotNET跨平台】
前面效果中基于ListBox实现了一点不一样的效果;今天再次在原来的基础上完善框选ListBox;最终实现的效果,如下图:
1、使用了VisualTreeHelper的HitTest方法:
Point point2 = e.GetPosition(LedListBox);
Rect rect = new Rect(origContentMouseDownPoint, point2);
RectangleGeometry rectangleGeometry = new RectangleGeometry(rect);
VisualTreeHelper.HitTest(LedListBox, new HitTestFilterCallback(OnHitTestFilterCallback), new HitTestResultCallback(OnHitTestResultCallback), new GeometryHitTestParameters(rectangleGeometry));
2、关于OnHitTestFilterCallback:
private HitTestFilterBehavior OnHitTestFilterCallback(DependencyObject target)
{
UIElement element = target as UIElement;
if(element != null)
{
var img = element as CheckBox;
if(img != null && img.IsVisible == true)
{
img.IsChecked = true;
return HitTestFilterBehavior.Continue;
}
}
return HitTestFilterBehavior.Continue;
}
最终简单的效果先这样吧;以后有时间的话,可以再去摸索一下更复杂的效果;编程不息、Bug不止、无Bug、无生活;改bug的冷静、编码的激情、完成后的喜悦、挖坑的激动 、填坑的兴奋;这也许就是屌丝程序员的乐趣吧;今天就到这里吧;希望自己有动力一步一步坚持下去;生命不息,代码不止;大家抽空可以看看今天分享的效果,有好的意见和想法,可以在留言板随意留言;我看到后会第一时间回复大家,多谢大家的一直默默的关注和支持!如果觉得不错,那就伸出您的小手点个赞并关注一下!
边栏推荐
- [Li Kou] the second set of the 280 Li Kou weekly match
- 简述C语言中的符号和链接库
- 【Qt5】Qt QWidget立刻出现并消失
- three. JS page background animation liquid JS special effect
- 2.2 fonctionnement stm32 GPIO
- Blue Bridge Cup - day of week
- 1.16 - check code
- C language circular statement
- Force buckle 1189 Maximum number of "balloons"
- [padding] an error is reported in the prediction after loading the model weight attributeerror: 'model' object has no attribute '_ place‘
猜你喜欢
[risc-v] external interrupt
2.2 STM32 GPIO操作
BUAA喜鹊筑巢
1. New project
深入刨析的指针(题解)
Multi project programming minimalist use case
ASU & OSU | model based regularized off-line meta reinforcement learning
【RISC-V】外部中断
Tidb ecological tools (backup, migration, import / export) collation
Schnuka: 3D vision detection application industry machine vision 3D detection
随机推荐
施努卡:什么是视觉定位系统 视觉系统如何定位
three. JS page background animation liquid JS special effect
Crazy, thousands of netizens are exploding the company's salary
Cross origin cross domain request
【SLAM】lidar-camera外参标定(港大MarsLab)无需二维码标定板
JS music online playback plug-in vsplayaudio js
The real machine cannot access the shooting range of the virtual machine, and the real machine cannot Ping the virtual machine
教你用Pytorch搭建一个自己的简单的BP神经网络( 以iris数据集为例 )
Align items and align content in flex layout
C language circular statement
MPLS experiment
3.1 detailed explanation of rtthread serial port device (V1)
Data analysis Seaborn visualization (for personal use)
Containerization Foundation
[optimization model] Monte Carlo method of optimization calculation
Svg drag point crop image JS effect
[Qt5] QT QWidget immediately appears and disappears
C language judgment, ternary operation and switch statement usage
Cubemx 移植正点原子LCD显示例程
1、工程新建