views:

208

answers:

1

I have a control derived from ComboBox, i want to use the ComboBox ControlTemplate, and just set a few values on it in xaml, namely the ItemContainerStyle. The code below doesnt work, the last setter, which im intending to apply the base ComboBox control template to this one, doesnt do anything.

   <Style
      TargetType="{x:Type local:EditingFilteringComboBox}"
      BasedOn="{StaticResource {x:Type ComboBox}}">
      <Setter
         Property="IsEditable"
         Value="False" />
      <Setter
         Property="DisplayMemberPath"
         Value="DisplayValue" />
      <Setter
         Property="ItemContainerStyle"
         Value="{StaticResource editingFilteringComboBoxListBoxItem}" />
      <Setter
         Property="Template"
         Value="{StaticResource {x:Type ComboBox}}" />
   </Style>

I want to derive from combo box but i dont want to include the whole control template for it. I dont even want to touch the control template. I do want to change the ItemContainerStyle, which i could do from code, but much nicer if i dont have to.

the other reason why i want this here is because to want access to the internal members of the ComboBox's control template, namely the TextBox and the Popup. Usually i access members like this in the override of OnApplyTemplate.

i feel like im travelling the wrong path, enlighten me sensei.

A: 

false alarm,

i wasnt including a link to this file in my generic.xaml

oh and i didnt have to set the Template value

   <Style
      TargetType="{x:Type local:EditingFilteringComboBox}"
      BasedOn="{StaticResource {x:Type ComboBox}}">
      <Setter
         Property="IsEditable"
         Value="False" />
      <Setter
         Property="DisplayMemberPath"
         Value="DisplayValue" />
      <Setter
         Property="ItemContainerStyle"
         Value="{StaticResource editingFilteringComboBoxListBoxItem}" />
   </Style>

the style will only set properties that are different from the base style. so as i dont want to change the control template i simply dont set it. OnApplyTemplate is called, and i can access the internals of the ComboBox's control template.

Aran Mulholland