The following control template code (from generic.xaml) gives me an error, 'The attached property ControlTemplate.Triggers' is not defined on 'Grid' or one of its base classes. Any help is appreciated.
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:TestCustomExpander">
<Style TargetType="local:CustomExpander">
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
<Setter Property="VerticalContentAlignment" Value="Stretch"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="local:CustomExpander">
<Grid Background="Transparent">
<Grid.Resources>
<LinearGradientBrush x:Key="ExpanderArrowFill" EndPoint="0,1" StartPoint="0,0">
<GradientStop Color="White" Offset="0"/>
<GradientStop Color="#FFBFBFBF" Offset="0.5"/>
<GradientStop Color="#FF878787" Offset="1"/>
</LinearGradientBrush>
<LinearGradientBrush x:Key="ExpanderArrowHoverFill" EndPoint="0,1" StartPoint="0,0">
<GradientStop Color="#FFF0F8FE" Offset="0"/>
<GradientStop Color="#FFE0F3FE" Offset="0.3"/>
<GradientStop Color="#FF6FA7C5" Offset="1"/>
</LinearGradientBrush>
<LinearGradientBrush x:Key="ExpanderArrowPressedFill" EndPoint="0,1" StartPoint="0,0">
<GradientStop Color="#FFDCF0FA" Offset="0"/>
<GradientStop Color="#FFC5E6F7" Offset="0.2"/>
<GradientStop Color="#FF5690D0" Offset="1"/>
</LinearGradientBrush>
<ControlTemplate x:Key="ExpanderDownHeaderTemplate" TargetType="ToggleButton">
<Grid Background="Transparent" Height="25">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CheckStates">
<VisualStateGroup.Transitions>
<VisualTransition GeneratedDuration="00:00:00"/>
</VisualStateGroup.Transitions>
<VisualState x:Name="Checked">
<Storyboard>
<DoubleAnimation BeginTime="0" Storyboard.TargetName="imgTransform" Storyboard.TargetProperty="Angle" From="90" To="180" Duration="0:0:.2" />
</Storyboard>
</VisualState>
<VisualState x:Name="Unchecked">
<Storyboard>
<DoubleAnimation BeginTime="0" Storyboard.TargetName="imgTransform" Storyboard.TargetProperty="Angle" From="180" To="90" Duration="0:0:.2" />
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Border Padding="{TemplateBinding Padding}">
<Grid Background="Transparent">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="10"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid HorizontalAlignment="Left" VerticalAlignment="Center">
<Grid x:Name="grdHeaderGrid" Height="19" Width="Auto" HorizontalAlignment="Left" VerticalAlignment="Center">
<Path Data="M 0,2.5 3,2.5 1.5,0 Z" Stroke="Black" StrokeThickness="5" Fill="Black" HorizontalAlignment="Left" VerticalAlignment="Center">
<Path.RenderTransform>
<RotateTransform x:Name="imgTransform" Angle="90" CenterX="0" CenterY="0" />
</Path.RenderTransform>
</Path>
</Grid>
</Grid>
<ContentPresenter x:Name="header" HorizontalAlignment="Stretch" Margin="4,0,0,0" VerticalAlignment="Center" Grid.Column="1" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}"/>
</Grid>
</Border>
<Rectangle x:Name="FocusVisualElement" Stroke="#FF448DCA" StrokeThickness="1" IsHitTestVisible="false" Visibility="Collapsed"/>
</Grid>
</ControlTemplate>
</Grid.Resources>
<Border x:Name="Background" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="0">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition x:Name="cd0" Width="Auto"/>
<ColumnDefinition x:Name="cd1" Width="Auto"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition x:Name="rd0" Height="Auto"/>
<RowDefinition x:Name="rd1" Height="Auto"/>
</Grid.RowDefinitions>
<Image x:Name="NormalImage" Source="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=NormalImageSource}"
HorizontalAlignment="Center" VerticalAlignment="Center" Stretch="UniformToFill"/>
<Image x:Name="PressedImage" Source="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=PressedImageSource}"
HorizontalAlignment="Center" VerticalAlignment="Center" Stretch="UniformToFill" Visibility="Collapsed"/>
<Image x:Name="DisabledImage" Source="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=DisabledImageSource}"
HorizontalAlignment="Center" VerticalAlignment="Center" Stretch="UniformToFill" Visibility="Collapsed"/>
<!--<Image x:Name="MouseOverImage" Source="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=MouseOverImageSource}"
HorizontalAlignment="Center" VerticalAlignment="Center" Stretch="UniformToFill" Visibility="Collapsed" />-->
<ToggleButton x:Name="ExpanderButton" FontFamily="{TemplateBinding FontFamily}" FontSize="{TemplateBinding FontSize}" FontStretch="{TemplateBinding FontStretch}" FontStyle="{TemplateBinding FontStyle}" FontWeight="{TemplateBinding FontWeight}" Foreground="{TemplateBinding Foreground}" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" Padding="{TemplateBinding Padding}" Template="{StaticResource ExpanderDownHeaderTemplate}" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" MinHeight="0" MinWidth="0" Content="{TemplateBinding Header}" ContentTemplate="{TemplateBinding HeaderTemplate}" Grid.Column="0" Grid.Row="0" IsChecked="{TemplateBinding IsExpanded}" Margin="{TemplateBinding HeaderMargin}"/>
<ContentControl x:Name="ExpandSite" FontFamily="{TemplateBinding FontFamily}" FontSize="{TemplateBinding FontSize}" FontStretch="{TemplateBinding FontStretch}" FontStyle="{TemplateBinding FontStyle}" FontWeight="{TemplateBinding FontWeight}" Foreground="{TemplateBinding Foreground}" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Visibility="Collapsed" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" Grid.Column="0" Grid.Row="1"/>
</Grid>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsExpanded" Value="True">
<Setter TargetName="ExpandSite"
Property="Visibility"
Value="Visible"/>
</Trigger>
</ControlTemplate.Triggers>
<Border x:Name="DisabledVisualElement" IsHitTestVisible="false" Opacity="0" Background="#A5FFFFFF" CornerRadius="0"/>
<Border x:Name="FocusVisualElement" IsHitTestVisible="false" Visibility="Collapsed" BorderThickness="1" CornerRadius="0">
<Border.BorderBrush>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#FFA3AEB9"/>
<GradientStop Color="#FF8399A9" Offset="0.375"/>
<GradientStop Color="#FF718597" Offset="0.375"/>
<GradientStop Color="#FF617584" Offset="1"/>
</LinearGradientBrush>
</Border.BorderBrush>
</Border>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
The following code snippetcode has some issue, I don't know where to place it.
<ControlTemplate.Triggers>
<Trigger Property="IsExpanded" Value="True">
<Setter TargetName="ExpandSite"
Property="Visibility"
Value="Visible"/>
</Trigger>
</ControlTemplate.Triggers>