I created two custom ComboBox controls, both inherit from the default ComboBox control.
public BlueComboBox : ComboBox {}
public WhiteComboBox : ComboBox {}
BlueComboBox contains a template and is styled properly and works perfectly. WhiteComboBox is a bit more complex. It contains a template consisting of a TextBlock and a BlueComboBox.
Incorrect snippet, but you should get the idea:
<ControlTemplate>
<Grid>
<TextBlock />
<BlueComboBox />
</Grid>
</ControlTemplate>
Here's the tricky part: since WhiteComboBox is a ComboBox control I would like to bind the items in BlueComboBox to the ones set in my WhiteComboBox control.
<WhiteComboBox>
<ComboBoxItem Content="Foo" />
<ComboBoxItem Content="Bar" />
</WhiteComboBox>
I tried binding the ItemSource of the BlueComboBox entity used in the template to the ItemsSource proprety of my WhiteComboBox, but that did not seem to work:
<ControlTemplate>
<Grid>
<TextBlock />
<BlueComboBox ItemsSource="{TemplateBinding ItemsSource}" />
</Grid>
</ControlTemplate>
What's the proper way to use the items defined in my WhiteComboBox instance to the BlueComboBox instance? Am I using the ItemsSource property incorrectly, or should I use another one?
Any help would be greatly appreciated.