码迷,mamicode.com
首页 > 其他好文 > 详细

WPF TabControl 模拟动画

时间:2014-07-09 00:10:33      阅读:597      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   os   cti   io   

 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 模拟动画

标签:style   blog   color   os   cti   io   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!