AddHandler

public MainWindow()
        {
            InitializeComponent();
            this.Loaded += new RoutedEventHandler(MainWindow_Loaded);
            this.button1.Click += new RoutedEventHandler(button1_Click);
            //AddHandler
            this.button1.AddHandler(Button.MouseRightButtonDownEvent, new RoutedEventHandler(Show), true);
        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            
        }

        private void Show(object sender,RoutedEventArgs e)
        {
            DoubleAnimation animation = new DoubleAnimation();
            animation.From = 0;
            animation.To = 1;
            animation.Duration = TimeSpan.FromSeconds(3);
            this.textBlock1.BeginAnimation(TextBlock.OpacityProperty, animation);
        }

        private void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
            
                        
        }
posted @ 2012-07-20 09:41  麦芽糖!  阅读(299)  评论(0编辑  收藏  举报