I'm facing with this problem,
I defined a custom usercontrol class which contains a controltemplate defined in XAML :
this is the class:
public class Master : Control { static Master() { DefaultStyleKeyProperty.OverrideMetadata(typeof(Master), new FrameworkPropertyMetadata(typeof(Master))); } public TranslateTransform SignalGridTransform { get { return (TranslateTransform)GetValue(SignalGridTransformProperty); } set { SetValue(SignalGridTransformProperty, value); } } public static readonly DependencyProperty SignalGridTransformProperty = DependencyProperty.Register("SignalGridTransform", typeof(TranslateTransform), typeof(Master), null); } }
Now, all I want to do is to start an animation on a target grid at upper (usercontrol sibling) level, if a button -inside- the usercontrol is pressed.
To achieve this I thought to pass the transform element that'll be used to target the property for animation, that's why the attribute SignalGridTransform is defined in class :
<Style TargetType="{x:Type EXOGear:Master}"><Setter Property="Template"><Setter.Value><ControlTemplate TargetType="{x:Type EXOGear:Master}"><StackPanel><StackPanel Margin="10"><ContentPresenter Content="{TemplateBinding ContentFrame}" /><Grid Name="ButtonsGrid" HorizontalAlignment="Right" Width="112" ><Button Background="Transparent" Name="Next" Width="71" Height="88"><Image Source="arrow-down.png"></Image><Button.Triggers><EventTrigger RoutedEvent="ButtonBase.Click"><EventTrigger.Actions><BeginStoryboard><Storyboard><DoubleAnimation BeginTime="0:0:0"
Storyboard.Target="{Binding SignalGridTransform, RelativeSource={RelativeSource TemplatedParent}}" Storyboard.TargetProperty="Y" From="0" To="-800" DecelerationRatio="0.0" Duration="00:00:00.500" /><DoubleAnimation BeginTime="0:0:0.500"
Storyboard.Target="{Binding SignalGridTransform, RelativeSource={RelativeSource TemplatedParent}}" Storyboard.TargetProperty="Y" From="800" To="0" DecelerationRatio="0.5" Duration="00:00:01.00" /></Storyboard></BeginStoryboard></EventTrigger.Actions></EventTrigger></Button.Triggers></Button></Grid></StackPanel></StackPanel></ControlTemplate></Setter.Value></Setter></Style><EXOGear:Master SignalGridTransform="{Binding ElementName=grdTrans }" /><Grid Name="mainGrid" HorizontalAlignment="Left" VerticalAlignment="Top" Width="694" Height="1261" ><Grid.RenderTransform ><TransformGroup ><TranslateTransform x:Name="grdTrans" X="0" Y="0" /></TransformGroup></Grid.RenderTransform><TextBlock> This Text Will Scroll</TextBlock></Grid>
The ScaleTransform Element, seems to be correctly passed o the usercontrol via the binding :
Storyboard.Target="{Binding SignalGridTransform, RelativeSource={RelativeSource TemplatedParent}}" Storyboard.TargetProperty="Y"
but no animation takes place.. Any Explanation for this behaviour ?
Thanks for any help on this, Marco
Marco Orlandi EXO System Italia SRL