首页 > 代码库 > WPF TabControl 模拟动画
WPF TabControl 模拟动画
1 public class MyTabControl : TabControl 2 { 3 4 Timer t = null; 5 protected override void OnSelectionChanged(SelectionChangedEventArgs e) 6 { 7 Action a = () => 8 { 9 try10 {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 try37 {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 }
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。