Q: WHY SHOULD I BOTHER WRAPPING ITEMS IN A COMBOBOXITEM?

Awadhendra Tiwari

Total Post:510

Points:2550
Posted by  Awadhendra Tiwari
WPF 
WPF
 1357  View(s)
Ratings:
Rate this:
  1. Awadhendra Tiwari

    Post:510

    Points:2550
    Q: Why should I bother wrapping items in a ComboBoxItem?

    ComboBoxItem exposes some useful properties—IsSelected andIsHighlighted—and
    useful events—Selected and Unselected. Using ComboBoxItem also avoids a quirkybehavior with showing content controls in the selection box (when IsEditable isfalse): If an item in a ComboBox is a content control, the entire controldoesn’t get displayed in the selection box. Instead, the inner content isextracted and shown. By using ComboBoxItem as the outermost content control,the inner content is now the entire control that you probably wanted to bedisplayed in the first place.
    Because ComboBoxItem is a content control, it is also handy for adding simplestrings to a
    ComboBox (rather than using something like TextBlock or Label).

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!