开发者

Referencing a base types control template in xaml

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 doesn't work, the last setter, which im intending to apply the base ComboBox control template to this one, doesn't 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 ComboBox 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 l开发者_如何学Goike this in the override of OnApplyTemplate.

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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜