0

I expect the following Style to affect any Border that is child of the Expander object to which this Style is applied to have a 1-pixel thick gray border. Why doesn't it work?

<Style TargetType="Expander">
  <Setter Property="ContentTemplate">
    <Setter.Value>
      <DataTemplate>
        <Border>
          <Border.Resources>
            <Style TargetType="Border">
              <Setter Property="BorderBrush" Value="Gray" />
              <Setter Property="BorderThickness" Value="1" />
            </Style>
          </Border.Resources>
          <ContentPresenter Content="{Binding}" />
        </Border>
      </DataTemplate>
    </Setter.Value>
  </Setter>
</Style>
dotNET
  • 33,414
  • 24
  • 162
  • 251
  • Element will check for implicit style through whole visual tree only if it inherits from `System.Windows.Controls.Control`. If it doesn't (like `TextBlock` or `Border`), and is placed in template, will check only in that template and `Application.Resources` skipping whole visual tree – dkozl Apr 30 '16 at 20:20
  • @dkozl: grrrrrr... but thanks for pointing out. – dotNET Apr 30 '16 at 20:23
  • 1
    Check [this](http://stackoverflow.com/questions/2476305/wpf-some-styles-not-applied-on-datatemplate-controls) answer – dkozl Apr 30 '16 at 20:29

0 Answers0