首页 > 其他 > 详细

WPF TabControl 模拟动画

时间:2014-07-09 00:10:57      阅读:873      评论:0      收藏:0      [点我收藏+]
 1  public class MyTabControl : TabControl
 2     {
 3 
 4         Timer t = null;
 5         protected override void OnSelectionChanged(SelectionChangedEventArgs e)
 6         {
 7             Action a = () =>
 8             {
 9                 try
10                 {
11                     var control = e.Source as MyTabControl;
12                     if (control == null) return;
13                     base.OnSelectionChanged(e);
14                     left = 80;
15                     var selectItem = control.SelectedContent as Grid;
16                                 
17                     selectItem.Visibility = Visibility.Collapsed;
18 
19                     t = new Timer(Move, selectItem, 0, 2);
20                 }
21                 catch (Exception)
22                 {
23 
24                     MainPanelWindow.TimerManager(true);
25                 }
26             };
27             this.Dispatcher.BeginInvoke(a);
28         }
29 
30         private int left = 80;
31         public void Move(object o)
32         {
33 
34             Action a = () =>
35             {
36                 try
37                 {
38                     left -= 6;
39                     if (left <= 0)
40                     {
41                         t.Dispose();
42                
43                         return;
44                     }
45 
46 
47                     var selectItem = o as Grid;
48                     if (selectItem == null) return;
49                 
50                     selectItem.Visibility = Visibility.Visible;
51                     selectItem.Margin = new Thickness(left, 0, 0, 0);
52                 }
53                 catch (Exception)
54                 {
55 
56                 }
57             };
58             this.Dispatcher.BeginInvoke(a);
59         }
60 
61  }

 

WPF TabControl 模拟动画,布布扣,bubuko.com

WPF TabControl 模拟动画

原文:http://www.cnblogs.com/gaobing/p/3830275.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!