コード例 #1
0
ファイル: MajorsPage.xaml.cs プロジェクト: Woody-Hu/WPFDemo
        protected override void OnMouseMove(MouseEventArgs e)
        {
            if (_imageButtons == null)
            {
                return;
            }

            foreach (var oneImageButton in _imageButtons)
            {
                var images = ButtonImages.GetButtonImages(oneImageButton);
                if (images == null)
                {
                    return;
                }

                if (oneImageButton.IsMouseOver)
                {
                    var image = images[1];
                    oneImageButton.Content = image;
                }
                else
                {
                    var image = images[0];
                    oneImageButton.Content = image;
                }
            }


            base.OnMouseMove(e);
        }
コード例 #2
0
        public static void OnImageButtonMouseOver(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            var imageButton = d as ImageButton;

            if (imageButton == null)
            {
                return;
            }

            var images = ButtonImages.GetButtonImages(imageButton);

            if (images == null)
            {
                return;
            }

            if ((bool)e.NewValue)
            {
                var image = images[1];
                imageButton.Content = image;
            }
            else
            {
                var image = images[0];
                imageButton.Content = image;
            }
        }
コード例 #3
0
        private static void Button_MouseEnter(object sender, MouseEventArgs e)
        {
            var imageButton = sender as ImageButton;

            if (imageButton != null && ButtonImages.GetButtonImages(imageButton) == null)
            {
                ((Button)sender).Margin = new Thickness(-5);
            }
        }