Im working on a custom control that derives from a button, I have 2 column definitions column 0 is set to grid length * and column 1 is set to auto. Column 0 has a few control in it and is working ok, column 1 has a grid that's width is set to 0, this is all set in the control template. The custom control I made has several dependency properties I have put in, and one of them is a bool type eg IsShowingInfoPlane and has default value of false, id like to attach a double animation on the grid that is in column 1 width to this dependency property so if its true run the animation from 0 to 150 and if its false run from 150 to 0 that is in column 1 which has a default value of 0. Im sure I have to go down the data trigger route as the style ones are not accepting animations.
Here is the dependency property of the button
public bool IsShowingInfoPlane
{
get { return (bool)GetValue(IsShowingInfoPlaneProperty); }
set
{
SetValue(IsShowingInfoPlaneProperty, value);
OnPropertyChanged("IsShowingInfoPlane");
}
}
and here is the data trigger I have tried to attach to the grid in column 1 that I want to animate on its width property
<Grid.Triggers>
<DataTrigger Binding="{TemplateBinding IsShowingInfoPlane}" Value="True" >
<DataTrigger.EnterActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Duration="0:0:0.150" From="{Binding ElementName=InfoGrid, Path=Width}" To="150" Storyboard.TargetProperty="Width" />
</Storyboard>
</BeginStoryboard>
</DataTrigger.EnterActions>
</DataTrigger>
</Grid.Triggers>
As Im going to have many of these buttons on the frontend I don't fancy creating individual animations and as Im so far down the road with this button I cant go and use other peoples controls. Ive used animations elsewhere in the program with success but this is the first time ive tried to use them with triggers, usually I can them from code and attach them to some control, Any help would be much appreciated.
Regards