开发者

WPF "Selected" Property of Custom Control or "Logical Focus". What should be used?

开发者 https://www.devze.com 2022-12-13 18:55 出处:网络
In my WPF project I have a custom control which is visually represented by a rectangle object. In XAML I put a number of rectangles based on this custom control. User should be able to select a group

In my WPF project I have a custom control which is visually represented by a rectangle object. In XAML I put a number of rectangles based on this custom control. User should be able to select a group of these rectangles by mouse clicks and then do some actions with these selected rectangles.

How I should implement the possibility of selection: (1) should I simply add yet another custom property e.g. "Selected" and change it in MouseClick event handlers or (2) should I use native 开发者_如何学编程"Logical Focus" functionality?


I'd argue that if you're building selection logic into your control, you may be duplicating functionality already provided by existing Selector subclasses such as ListBox.

Why not just host instances of your control inside a ListBox and let it do the selection logic?

0

精彩评论

暂无评论...
验证码 换一张
取 消