Reputation: 3396
I've just been fooling around with a ListBox control that I want to style a certain way. For now it looks just like I want it to with rounded corners and no padding. However, the rounded corners seems to cause a problem with the items in the ListBox.
A screenshot so you can see what I mean: alt text http://www.bo-mortensen.dk/listbox.JPG
The thing is, that the first and the last item in the listbox needs to have it's corners rounded aswell. So the first item in the listbox needs to have it's upper left and right corners rounded while the bottom corners needs to be rectangular.
Is it possible in some way, to make three different styles and have the first, middle and last items use their own style? So i.e:
Also, as a side question, how am I able to style the selected item and mouse over? If i'd like to get rid of the blue rectangle that's standard.
Hope you understand my question(s), if not - just let me know and I'll see if I can elaborate :)
Thanks in advance!
Upvotes: 0
Views: 1026
Reputation: 29196
what you need is an DataTemplateSelector. this allows you to have different templates for different items in the listbox based on whatever criteria you specify.
check Dr. WPF for a pretty decent example (about 1/2 way down the page)
another tutorial is at Switch On The Code
and everybody's favorite, Bea Stollnitz
Upvotes: 1