I want to have a wpf combobox that displays the dropdown list box with the options grouped under a heading like the <optgroup> behaviour in html. Has anyone seem something like this done before?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
See How to: Sort and Group Data Using a View in XAML. You apply a grouping to the CollectionView for your data and then set the GroupStyle on the ComboBox. Done entirely XAML, it would look like this:
Or you could apply the grouping in code:
And use the default collection view in Xaml:
You could customize the look of the grouped data by providing a custom GroupStyle with your own HeaderTemplate.