首页 > 其他分享 >WPF Button MouseEnter and MouseLeave together play as MouseOver

WPF Button MouseEnter and MouseLeave together play as MouseOver

时间:2024-08-25 21:07:00浏览次数:3  
标签:MouseLeave play Windows Button System using btn MouseEnter

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace WpfApp286
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        Button btn { get; set; }
        public MainWindow()
        {
            InitializeComponent();
            ButtonMouseEnterMouseLeave();
        }

        private void ButtonMouseEnterMouseLeave()
        {
            btn = new Button();
            btn.Content = "Button!";
            btn.FontSize = 30;
            btn.Width = 300;
            btn.Height = 100;
            btn.Background = new SolidColorBrush(Colors.Red);
            btn.MouseEnter += Btn_MouseEnter;
            btn.MouseLeave += Btn_MouseLeave;
            this.Content = btn;
        }

        private void Btn_MouseLeave(object sender, MouseEventArgs e)
        {
            btn.Background = new SolidColorBrush(Colors.Red);
        }

        private void Btn_MouseEnter(object sender, MouseEventArgs e)
        {
            btn.Background = new SolidColorBrush(Colors.Blue);
        }
    }
}

 

标签:MouseLeave,play,Windows,Button,System,using,btn,MouseEnter
From: https://www.cnblogs.com/Fred1987/p/18379551

相关文章

  • [HTML 5] Autoplay video
    Normalbrowserhasrestictionthatdoesn'tallowyouautomaticllyplaythevideo,unlessyoursitehashighMediaEnagementindex(MEI).Thereare2waytoresolvethisproblem.1.ClickandPlayasyncfunctionplay(){try{awaitvdo.pl......
  • WPF Button Command and CommandParamet completed via C# no xaml at all
    privatevoidButtonCommandBinding(){Buttonbtn=newButton();btn.Width=500;btn.Height=300;btn.Content="ShowInfo";btn.Background=newSolidColorBrush(Colors.Blue);btn.Command=ShowCmd;......
  • IconButton的用法
    文章目录1.概念介绍2.使用方法2.1filled风格2.2filledTonal风格2.3outlined风格3.代码与效果3.1示例代码3.2运行效果4.内容总结我们在上一章回中介绍了"如何修改NavigationBar组件的形状"相关的内容,本章回中将介绍IconButtion组件.闲话休提,让我们一起Talk......
  • QuickTime Player媒体播放器软件安装包下载地址及安装教程!
    软件介绍QuickTimePlayer中文版是苹果公司开发的一款功能强大的媒体播放器。除了播放MP3外,还支持MIDI播放,并且可以收听/收看网络播放,支持HTTP、RTP和RTSP标准。该软件还支持主要的图像格式,比如:JPEG、BMP、PICT、PNG和GIF。软件:QuickTime版本:7.7.9语言:简体中文大小:40.1M安......
  • Playbook剧本案例实战
    script模块script模块⽤于在远程机器上执⾏本地脚本。#在master上准备⼀个脚本[root@m0~]#vimtest.shmkdir/tmp/threetouch/tmp/three/testecho'iamecho,isusedwrite'>/tmp/three/test[root@m0~]#sourcetest.sh#在group02的远程机器⾥都执⾏master上的......
  • Android Kotlin优化代码整洁:with、applay以及run是什么,作用,区别
    目录为什么需要使用with、applay以及runwith、applay以及run是什么、作用以及三者区别一、为什么需要使用with、applay以及run我们在开发项目的过程当中,不可避免,一个界面的内容会有很多,如下initivew方法,会有Recyclerview的初始化,长按以及触摸事件设置,以及生命周期的注册,主......
  • 解锁私人音乐宇宙:SPlayer智能推荐,每日新发现,乐趣无限升级!
    前言在快节奏的工作生活中,你是否经常为了寻找一首好听的歌曲而烦恼?如果有一款音乐播放器,它不仅能让你轻松找到喜欢的歌曲,而且还是开源免费使用;这听起来是不是很吸引人呢?而SPlayer正是这样的一款音乐播放器!无论是在家休闲娱乐,还是在办公室专注工作,都能提供最贴心的音乐享......
  • Playbook
    yum_repository模块yum_repository模块⽤于配置yum仓库。https://docs.ansible.com/ansible/latest/modules/yum_repository_module.html增加⼀个/etc/yum.repos.d/local.repo配置⽂件删除/etc/yum.repos.d/local.repo配置⽂件yum模块(重点)yum模块⽤于使⽤yum命令来......
  • 2024.8.20(playbook剧本安装nginx、roles)
    一、playbook 剧本安装nginx[root@m0~]#mkdir/etc/ansible/playbook[root@m0~]#vim/etc/ansible/playbook/nginx.yml----hosts:group02remote_user:roottasks:-name:卸载httpdyum:......
  • Docker+Win11:显示Docker中的GUI,解决报错“[Open3D WARNING] GLFW Error: X11: Failed
        在本系列博文中,我将Pytorch部署在Win11为宿主的Docker中,并成功的调用GPU进行了训练。这为我提供了很多便利。    今天在进行3D相关的深度学习研究时我遇到了一些问题:[Open3DWARNING]GLFWError:X11:Failedtoopendisplay:0[Open3DWARNING]Faile......