I have a custom user control with a bool Selected variable, and code that checks if it is selected, and if so it highlights it, if it’s not selected, it hides the highlight. simple enough.
Now, I have a panel that’s filled with that object, and I need it to work similar to any files explorer (such as Windows Explorer). I mean by that, that if you click the item, it selects itself. that’s not a problem, it’s just a mouse click. the problem comes in when the user wants to select other items instead.
What I basically want is:
Whenever the user clicks on an item, all other items deselects and such.
I was trying to find the best way to do it, all that came to my mind is have a parent class that directs those operations (changes the bool, and call the update function) but it seems too sloppy, and maybe a bit complicated. any suggestions?
Thanks.
The most common approach would be a “collection” component, which manages rules such as how many could be selected and exposes useful information and events (such as SelectedItem and SelectedItemChanged).