20

I am trying to creating a combobox with checkboxes on each line to allow multiple selecting. Would this be better as a User Control or Custom Control?

I haven't created a control before so just looking for a little advice on what direction I need to head.

Thanks.

Darren Young
  • 10,972
  • 36
  • 91
  • 150

2 Answers2

67

UserControl (Composition)

  • Composes multiple existing controls into a reusable "group"
  • Consists of a XAML and a code behind file
  • Cannot be styled/templated
  • Derives from UserControl

CustomControl (Extending an existing control)

  • Extends an existing control with additional features
  • Consists of a code file and a default style in Themes/Generic.xaml
  • Can be styled/templated
  • The best approach to build a control library

In your case, I think UserControl would be better; here's an example for you:

<CheckBox Content="Property" IsChecked="{Binding Path=SomeProperty}" />
<ComboBox IsEnabled="{Binding Path=Enabled}" />
Mathieu Guindon
  • 69,817
  • 8
  • 107
  • 235
Irvin Dua
  • 771
  • 1
  • 7
  • 12
  • Welcome to SO. Please use simple formatting or take a good look at Markup help (on the right when you Edit). – H H Jun 08 '11 at 14:20
13

I would say use a datatemplate.

Like this: Looking for a WPF ComboBox with checkboxes

It's a lot more simple than trying to create your own control. :)

Community
  • 1
  • 1
Ashley Grenon
  • 9,305
  • 4
  • 41
  • 54
  • 10
    This answers the body of the question but not the title of the question. I came here by searching for the title. – Gilles Apr 30 '14 at 14:59