Click here to Skip to main content
15,922,574 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,
I am new in wpf. I have code in which I want to show button for certain time of period and then change his visibilty.

Here is my code

C#
Storyboard sb = new Storyboard();
           ObjectAnimationUsingKeyFrames objAn = new ObjectAnimationUsingKeyFrames();
           objAn.BeginTime = TimeSpan.FromSeconds(0);
           Storyboard.SetTarget(objAn, dock);
           Storyboard.SetTargetProperty(objAn, new PropertyPath(UIElement.VisibilityProperty));
           DiscreteObjectKeyFrame objd = new DiscreteObjectKeyFrame(Visibility.Visible, KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0)));
           objAn.KeyFrames.Add(objd);
           DiscreteObjectKeyFrame objd1 = new DiscreteObjectKeyFrame(Visibility.Hidden, KeyTime.FromTimeSpan(TimeSpan.FromSeconds(2)));
           objAn.KeyFrames.Add(objd1);
           sb.Children.Add(objAn);
           sb.BeginAnimation(UIElement.VisibilityProperty, objAn);


dock is my button name

Waiting for reply.
Posted
Updated 12-Dec-13 14:05pm
v3
Comments
Maciej Los 12-Dec-13 9:20am    
"Reply" to what?
We need more details to help understand what kind of issue do you have. We can't read in your mind and we don't see your screen. ;(

1 solution

its easier to control animation in xaml code where your storyboard lied there rather than creating storyboard in codebehind. . .
 
Share this answer
 
Comments
Dnyanesh Wahiley 13-Dec-13 0:01am    
Thanks for your kindly reply. I got the solution..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900