Click and drag selection box in WPF

后端 未结 4 1574
攒了一身酷
攒了一身酷 2020-11-30 21:53

Is it possible to implement mouse click and drag selection box in WPF. Should it be done through simply drawing a rectangle, calculating coordinates of its points and evalua

4条回答
  •  不思量自难忘°
    2020-11-30 22:21

    This project created a custom MultiSelector which supports several selection methods including a rectangular "lasso" style:

    Developing a MultiSelector by Teofil Cobzaru

    It is far too long to reproduce here. The key elements of the design, IIRC, were to create a custom ItemContainer which knows how to interact with its MultiSelector parent. This is analagous to ListBoxItem / ListBox.

    This is probably not the simplest possible approach, however if you are already using some type of ItemsControl to host the items which may need to be selected, it could fit into that design pretty easily.

提交回复
热议问题