Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > Avalon

Vista - Triggers Firing for Child Objects

 
 
Old 05-14-2007   #1 (permalink)
gregbacchus@nospam.nospam


 
 

Triggers Firing for Child Objects

I am trying to make an animated Expander, that slides open and closed.
It works fine, however when in put another Expander inside it, the
triggers/routed events seem to get a little confused. When the child
Expander is closed, it runs the CollapseMe Storyboard on the parent
(even if the child doesn't have the Animated Template). Of course I
don't want this to happen, because it's just weird.

Can anyone help me please

Cheers



<Window x:Class="WpfTest.Window4"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="WpfTest" Height="343" Width="407"
>

<Window.Resources>
<ControlTemplate x:Key="AnimatedExpander" TargetType="Expander">
<ControlTemplate.Resources>
<Storyboard x:Key="ExpandMe">
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00"
Duration="00:00:00.150"

Storyboard.TargetName="ContentBorder"

Storyboard.TargetProperty="(FrameworkElement.LayoutTransform).
(TransformGroup.Children)[0].(ScaleTransform.ScaleY)">
<LinearDoubleKeyFrame KeyTime="00:00:00.150" Value="1"/>
<DiscreteDoubleKeyFrame KeyTime="00:00:00.150" Value="1"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
<Storyboard x:Key="CollapseMe">
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00"
Duration="00:00:00.150"

Storyboard.TargetName="ContentBorder"

Storyboard.TargetProperty="(FrameworkElement.LayoutTransform).
(TransformGroup.Children)[0].(ScaleTransform.ScaleY)">
<LinearDoubleKeyFrame KeyTime="00:00:00.150" Value="0"/>
<DiscreteDoubleKeyFrame KeyTime="00:00:00.150" Value="0"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</ControlTemplate.Resources>
<StackPanel>
<ToggleButton Name="Header"
IsChecked="{Binding Path=IsExpanded,
Mode=TwoWay,
RelativeSource={RelativeSource
TemplatedParent}}"
Padding="0">
<ContentPresenter
Margin="4"
ContentSource="Header"
RecognizesAccessKey="True" />
</ToggleButton>
<Border Name="ContentBorder"
BorderBrush="LightGray"
BorderThickness="1"
Height="Auto">
<Border.LayoutTransform>
<TransformGroup>
<ScaleTransform ScaleX="1" ScaleY="1"/>
<SkewTransform AngleX="0" AngleY="0"/>
<RotateTransform Angle="0"/>
<TranslateTransform X="0" Y="0"/>
</TransformGroup>
</Border.LayoutTransform>
<ContentPresenter Margin="10"/>
</Border>
</StackPanel>
<ControlTemplate.Triggers>
<EventTrigger RoutedEvent="Expander.Expanded">
<EventTrigger.Actions>
<BeginStoryboard Storyboard="{StaticResource ExpandMe}"/>
</EventTrigger.Actions>
</EventTrigger>
<EventTrigger RoutedEvent="Expander.Collapsed">
<EventTrigger.Actions>
<BeginStoryboard Storyboard="{StaticResource CollapseMe}"/
>

</EventTrigger.Actions>
</EventTrigger>

</ControlTemplate.Triggers>
</ControlTemplate>

</Window.Resources>

<Grid>
<Expander Margin="30,36,45,44" Header="EXPANDER ONE"
IsExpanded="True" Template="{StaticResource AnimatedExpander}">
<Expander Height="120" Padding="4" Background="Gainsboro"
Header="CHILE EXPANDER" Width="160" IsExpanded="False">
<Button></Button>
</Expander>
</Expander>
</Grid>
</Window>


My System SpecsSystem Spec
 

Thread Tools


Similar Threads
Thread Forum
Enumeration of NTFS Permissions including child objects.... VB Script
DataGridView firing way to many SelectionChangedEvents! Please Help .NET General
Linkbutton firing every other time issue .NET General
firing noise in wmp11 Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46