none
Wpf程序最小化后,无法重新激活 RRS feed

  • 问题

  • Wpf程序最小化后,放置一段时间不用,等到平板熄屏后,重新点亮屏幕,却无法重新激活程序,让程序弹出

    请教下这个是什么原因造成的。

    谢谢<tbdiv id="playerControlBtn"></tbdiv><tbdiv id="leftFullStackButton"></tbdiv><tbdiv id="rightFullStackButton"></tbdiv>

    2016年12月2日 1:07

全部回复


  • Hi touhou_fantasy,

    从你的描述,不太清楚是什么原因。 我建议你可以尝试使用 NotifyIcon 来实现程序最小化和显示。 你可以参考下面简单的代码。

          WindowState ws;
            WindowState wsl;
            NotifyIcon notifyIcon;
            public WPFwindowsshowhide()
            {
                InitializeComponent();
                icon();
                wsl = WindowState;
            }
    
            private void icon()
            {
                this.notifyIcon = new NotifyIcon();
                this.notifyIcon.BalloonTipText = "你好,程序开启";
                this.notifyIcon.Text = "程序--运行中";
                this.notifyIcon.Icon = new System.Drawing.Icon("favicon.ico");
                this.notifyIcon.Visible = true;
                notifyIcon.MouseDoubleClick += OnNotifyIconDoubleClick;
                this.notifyIcon.ShowBalloonTip(500);
            }
    
            private void OnNotifyIconDoubleClick(object sender, EventArgs e)
            {
                this.Show();
                WindowState = wsl;
            }
    
            private void Window_StateChanged(object sender, EventArgs e)
            {
                ws = WindowState;
                if (ws == WindowState.Minimized)
                {
                    this.Hide();
                }
            }

    Best Regards,

    Yohann Lu



    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    2016年12月2日 6:53
    版主