2012-02-15 99 views
0

如果你在里面创建应用并显示模态窗口,然后点击模态外,你的窗口将会'闪烁'。如何将“闪烁”效果添加到自定义控件?

如何使用自定义控件完成,而不是Windows?

+0

你的意思是“闪烁”,当你用户'.ShowDialog()' – 2012-02-15 09:20:57

+0

是的,与模式模式。 – 2012-02-15 12:26:27

+0

我明白你指的是什么闪光,我只是不确定你想要什么样的效果?你想防止重点从你的自定义控制丢失,然后通过闪烁强调​​? – 2012-02-15 13:08:50

回答

0

您正在使用的自定义窗口不显示Windows标题栏,因此您看不到闪烁的效果。为了让你的自定义标题栏闪光,你必须做一些工作。

我不确定这会实际上工作,但你需要检测消息窗口发送到窗口使其闪烁。查看here,了解如何获得窗口收到的消息的通知。这是该页面的代码:

using System; 
using System.Windows; 
using System.Windows.Interop; 

namespace WpfApplication1 
{ 
    public partial class Window1 : Window 
    { 
     public Window1() 
     { 
      InitializeComponent(); 
     } 

     protected override void OnSourceInitialized(EventArgs e) 
     { 
      base.OnSourceInitialized(e); 
      HwndSource source = PresentationSource.FromVisual(this) as HwndSource; 
      source.AddHook(WndProc); 
     } 

     private IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled) 
     { 
      // Write some debug messages to the console here to detect what message is sent to the window when you click behind an active modal dialog 

      return IntPtr.Zero; 
     } 
    } 
} 

请注意我在代码中的注释。

如果这项工作,您可以从那里触发XAML中的动画来模仿闪烁的效果。

出于利益的考虑,应用程序是否在任务栏中闪烁?