Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/329.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# 如何解决winform中的UI延迟?_C#_Wpf_Winforms_Double Buffering_Elementhost - Fatal编程技术网

C# 如何解决winform中的UI延迟?

C# 如何解决winform中的UI延迟?,c#,wpf,winforms,double-buffering,elementhost,C#,Wpf,Winforms,Double Buffering,Elementhost,我在Winform中使用Elementhost添加了WPF用户控件。 加载表单时会出现闪烁。 因此,我添加了如下代码。 c#: WPF: 闪烁消失了。 我面临一个问题。 当我通过按住Backspace键从WPF usercontrol中的文本框中删除文本时,WPF usercontrol UI操作看起来并不平滑。延迟了。 当我在用户控件中键入长文本(“qwertyuiopasdfghjkl;zxcvbnm,”),然后按住Backspace键从用户控件中删除文本时,用户控件将有一个延迟,同时删除多

我在Winform中使用Elementhost添加了WPF用户控件。
加载表单时会出现闪烁。
因此,我添加了如下代码。
c#:

WPF:

闪烁消失了。
我面临一个问题。
当我通过按住Backspace键从WPF usercontrol中的文本框中删除文本时,WPF usercontrol UI操作看起来并不平滑。延迟了。
当我在用户控件中键入长文本(“qwertyuiopasdfghjkl;zxcvbnm,”),然后按住Backspace键从用户控件中删除文本时,用户控件将有一个延迟,同时删除多个字符。字符不会逐个擦除。
但是,如果我删除代码以防止闪烁,并且当我按住Backspace键时,usercontrol的字符会一个接一个地被删除


如何解决此问题?

“加载表单时会出现闪烁”-请在加载后尝试防止闪烁。@Sinatr谢谢。这很有帮助。
        protected override CreateParams CreateParams
        {
            get
            {
                CreateParams handleparam = base.CreateParams;
                handleparam.ExStyle |= 0x02000000;
                return handleparam;
            }
        }
        private void SearchTextBox_Loaded(object sender, RoutedEventArgs e)
        {
            HwndSource hwnd = System.Windows.PresentationSource.FromVisual(this) as HwndSource;
            HwndTarget target = hwnd.CompositionTarget;
            target.RenderMode = RenderMode.SoftwareOnly;

        }