Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何添加';闪烁';对自定义控件的影响?_C#_Wpf - Fatal编程技术网

C# 如何添加';闪烁';对自定义控件的影响?

C# 如何添加';闪烁';对自定义控件的影响?,c#,wpf,C#,Wpf,如果您创建应用程序并在内部显示模式窗口,然后单击外部模式,您的窗口将“闪烁” 如何使用自定义控件而不是windows完成此操作?您使用的自定义窗口不显示windows标题栏,因此您无法看到闪烁效果。要使自定义标题栏闪烁,您必须做一些工作 我不确定这是否真的有效,但您需要检测windows发送到该窗口的消息以使其闪烁。查看如何获得窗口收到的消息通知。这是该页面中的代码: using System; using System.Windows; using System.Windows.Interop

如果您创建应用程序并在内部显示模式窗口,然后单击外部模式,您的窗口将“闪烁”


如何使用自定义控件而不是windows完成此操作?

您使用的自定义窗口不显示windows标题栏,因此您无法看到闪烁效果。要使自定义标题栏闪烁,您必须做一些工作

我不确定这是否真的有效,但您需要检测windows发送到该窗口的消息以使其闪烁。查看如何获得窗口收到的消息通知。这是该页面中的代码:

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中的动画来模拟闪烁效果


出于兴趣,应用程序是否会在任务栏中闪烁?

您是指当您使用
时的“闪烁”。ShowDialog()
我理解您所指的闪烁,但我不确定您希望在哪里获得相同的效果?是否要防止焦点从自定义控件丢失,然后通过闪烁来强调这一点?因为我使用的是DevExpress窗口,这仍然只是一个带有自定义(主题化)标签的控件。我想用闪光效果来设计它,不需要预先渲染。