Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
260
custom header button + tile animation
posted

Hi,

I've added a new button on the header of my tile using a ToggleButton and a CommandSource in the TilePane ControlTemplate . I can capture the event when a user clicks on the button. The question I have for you is in the event where I handle the click of the button is it possible to fire a custom animation that will apply to that specific tile?

For example, I was thinking my button would toggle an animation that would flip that tile over exposing a different data template/user control on the back for configuring settings for the control on the front... or something like this :)

    public class SettingsCommand : Infragistics.Silverlight.CommandBase
    {
        public override bool CanExecute(object parameter)
        {
            return true;
        }

        public override void Execute(object parameter)
        {

               // for example, in here... how do I know what tile I'm clicking on, so I have a way to fire the correct animation on the tile? All I seem to have here is my original command source that I can't find the tile that it was attached too in the framework element tree
        }
    }

 

Any ideas?

Thanks,
Kevin

 

Parents
No Data
Reply
  • 3071
    Verified Answer
    posted

    Hi Kevin,
    You can pass the tile as a parameter:
    <Button Content="Settings" 
                 DataContext
    ="{Binding RelativeSource={RelativeSource TemplatedParent}}">
           <ig:Commanding.Command>
               <local:AppCommandSource EventName="Click" ParameterBinding="{Binding}"/>
           </ig:Commanding.Command>
    </
    Button>
    and then... it is easy:
    public override void Execute(object parameter)
    {
    TilePane tile = this.CommandSource.ParameterResolved as TilePane;
    RotateTransform rt = new RotateTransform();
    tile.RenderTransform = rt;
    tile.RenderTransformOrigin =
    new Point(0.5, 0.5);
    DoubleAnimation da = new DoubleAnimation();
    Storyboard.SetTarget(da, rt);
    Storyboard.SetTargetProperty(da, new PropertyPath("Angle"));
    Storyboard sb = new Storyboard();
    sb.Duration =
    new Duration(TimeSpan.FromMilliseconds(1000));
    da.Duration = sb.Duration;
    sb.Children.Add(da);
    sb.AutoReverse =
    false;
    da.From = 0;
    da.To = 360;
    sb.Begin();
    }
    Regards,
    Marin

     

     

Children