using System;
using System.Threading;
using System.Windows;
using System.Windows.Controls;
using WangCai.Common; namespace WangCai.Controls
{ public class MyTabControl : TabControl
{ Timer t = null;
private int left = ;
private int AnimationIndex = ;
protected override void OnSelectionChanged(SelectionChangedEventArgs e)
{
Action a = () =>
{
try
{
AnimationIndex++;
var control = e.Source as MyTabControl;
if (control == null) return;
base.OnSelectionChanged(e);
if (AnimationIndex % == )
{
left = -;
}
else
{
left = ;
} var selectItem = control.SelectedContent as ScrollViewer;
if (selectItem == null)
{ var selectItem_2 = control.SelectedContent as Grid;
if (selectItem_2 == null)
{
var selectItem_3 = control.SelectedContent as StackPanel;
if (selectItem_3 == null) return;
selectItem_3.Visibility = Visibility.Collapsed;
t = new Timer(Move, selectItem_3, , );
return;
}
selectItem_2.Visibility = Visibility.Collapsed;
t = new Timer(Move, selectItem_2, , );
return;
}
selectItem.Visibility = Visibility.Collapsed; t = new Timer(Move, selectItem, , ); }
catch (Exception)
{ }
};
this.Dispatcher.BeginInvoke(a);
} public void Move(object o)
{ Action a = () =>
{
try
{
if (AnimationIndex % == )
{
left +=;
if (left > )
{
t.Dispose(); return;
}
AnimationIndex = ;
}
else
{ left -= ; if (left <= )
{
t.Dispose(); return;
}
AnimationIndex = ;
} var selectItem = o as ScrollViewer;
if (selectItem == null)
{
var selectItem_2 = o as Grid;
if (selectItem_2 == null)
{
var selectItem_3 = o as StackPanel;
if (selectItem_3 == null) return;
selectItem_3.Visibility = Visibility.Visible;
selectItem_3.Margin = new Thickness(left, , , ); return;
}
selectItem_2.Visibility = Visibility.Visible;
selectItem_2.Margin = new Thickness(left, , , );
return;
}
selectItem.Visibility = Visibility.Visible;
selectItem.Margin = new Thickness(left, , , );
}
catch (Exception)
{ } };
this.Dispatcher.BeginInvoke(a);
} }
}

WPF TabControl 模拟动画的更多相关文章

  1. 使用WPF技术模拟手机界面

    原文:使用WPF技术模拟手机界面 1. 前言 WPF(Windows Presentation Foundation),即"Windows呈现基础",它的目的非常明确,就是用来把数 ...

  2. WPF中的动画——(三)时间线(TimeLine)

    WPF中的动画——(三)时间线(TimeLine) 时间线(TimeLine)表示时间段. 它提供的属性可以让控制该时间段的长度.开始时间.重复次数.该时间段内时间进度的快慢等等.在WPF中内置了如下 ...

  3. WPF编程学习——动画

    前言 使用动画,是增强用户体验的一种有效的手段.合理的动画,可以让应用程序的界面看起来更加自然.真实.流畅.舒适,更有效地向用户展现信息,用户也更容易接受.同时也增加了软件使用的乐趣,提高用户粘度.( ...

  4. WPF 跟随鼠标动画 by wgscd

    WPF 跟随鼠标动画 by wgscd <UserControl x:Class="WpfApplication1.Spark" xmlns="http://sch ...

  5. 【WPF学习笔记】[转]周银辉之WPF中的动画 && 晓风影天之wpf动画——new PropertyPath属性链

    (一)WPF中的动画 动画无疑是WPF中最吸引人的特色之一,其可以像Flash一样平滑地播放并与程序逻辑进行很好的交互.这里我们讨论一下故事板. 在WPF中我们采用Storyboard(故事板)的方式 ...

  6. WPF 有趣的动画效果

    WPF 有趣的动画效果         这一次我要呈上一个简单的文章,关于给你的WPF apps加入美丽的光线动画,可是我对动画这东西可能有点入迷了.         实际上.我对动画如此的入迷,以至 ...

  7. WPF 画线动画效果实现

    原文:WPF 画线动画效果实现 弄了将近三天才搞定的,真是艰辛的实现. 看了很多博客,都太高深了,而且想要实现的功能都太强大了,结果基础部分一直实现不了,郁闷啊~ 千辛万苦终于找到了一个Demo,打开 ...

  8. WPF特效-粒子动画

    原文:WPF特效-粒子动画 WPF实现泡泡龙小游戏效果.     /// -Ball to Ball Collision - Detection and Handling    /// http:// ...

  9. WPF 动态模拟CPU 使用率曲线图

    原文:WPF 动态模拟CPU 使用率曲线图      在工作中经常会遇到需要将一组数据绘制成曲线图的情况,最简单的方法是将数据导入Excel,然后使用绘图功能手动生成曲线图.但是如果基础数据频繁更改, ...

随机推荐

  1. ajax中加上AntiForgeryToken防止CSRF攻击

    经常看到在项目中ajax post数据到服务器不加防伪标记,造成CSRF攻击 在Asp.net Mvc里加入防伪标记很简单在表单中加入Html.AntiForgeryToken()即可. Html.A ...

  2. 集成架构:对比 Web API 与面向服务的架构和企业应用程序集成(转)

    http://kb.cnblogs.com/page/521644/ 摘要:总体上讲,SOA 和 Web API 似乎解决的是同一个问题:以实时的.可重用的方式公开业务功能.本教程将分析这些举措有何不 ...

  3. TinyFrame升级之二:数据底层访问部分

    在上一篇中,我列举了框架的整体结构,下面我们将一一说明: 首先需要说明的是TinyFrame.Data. 它主要用于处理数据库底层操作.包含EF CodeFirst,Repository,Unitof ...

  4. SSM三大框架整合详细教程(Spring+SpringMVC+MyBatis)

    使用 SSM ( Spring . SpringMVC 和 Mybatis )已经有三个多月了,项目在技术上已经没有什么难点了,基于现有的技术就可以实现想要的功能,当然肯定有很多可以改进的地方.之前没 ...

  5. LeetCode:Clone Graph

    题目如下:实现克隆图的算法  题目链接 Clone an undirected graph. Each node in the graph contains a label and a list of ...

  6. IOS 应用生命周期

    *当第一次运行程序时候:(active)didFinishLaunchingWithOptions(加载完毕)->applicationDidBecomeActive(获取焦点)*当点击home ...

  7. 报错:'Could not load NIB in bundle: 'NSBundle解决办法

    1.首先检查拼写是否正确: 2.断开连线,重新连接view与files' owner; 3.规避敏感View名.Xcode中有许多名字是系统预留的.你如果用了也会报这个错误.

  8. WPF开发时光之痕日记本

       很久没有写东西了,新的一年新的开始吧. 很早就想自己开发一款日记本软件不仅自己使用,也可以让大家免费使用,最主要的是对自己有一个认可,自学WPF以来,感觉不很顺利,WPF的资料相对来说有点少,主 ...

  9. Windows Azure 名词定义(Glossary)

    Glossary(名词) Definition(定义) Availability Set 可用性组 refers to two or more Virtual Machines deployed ac ...

  10. [USACO 1.5.4]checker(水题重做——位运算(lowbit的应用))

    描述 检查一个如下的6 x 6的跳棋棋盘,有六个棋子被放置在棋盘上,使得每行.每列有且只有一个,每条对角线(包括两条主对角线的所有平行线)上至多有一个棋子. 0 1 2 3 4 5 6 ------- ...