WPF Limit listbox selected items to a number /Select, unselect items in listbox

   I have a supposedly simple problem but I am not sure how to implement this. I have created a simple example of the issue with the below attached files. The two files are the ProductWindow xaml and cs file and the Product class file. I want to accomplish two things, please take a look at both and provide the code with your suggestion, thanks.

1) Limit the selected Items in the listbox to 3. How do I implement this for the listbox lbProducts? I didnt see a maxselecteditems property?!? or something similar.

2) This is a little more fun :) the second issue is I add the "All" Item to the datatable before binding the listbox. I would like to unselect other items if the All option is selected by the user and similarly unselect All if the user selected any other item. Also All should clear out the other selected items and we should limit the selected items to 3 only if All is not in the selected items? Hopefully that makes sense, please let me know if you need any other info, your help is really appreciated.  Please take the code from my simple example files below.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

I have solved both 1) and 2) (The code is attached)

I have added a variable called MaxItems(set to 3) in ProductWindow code and am handling the SelectionChanged event of the combobox.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
groovbox303Author Commented:
Thanks for your help cutebug, you rock!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.