In C#, how do you send a refresh/repaint message to a WPF grid or canvas?(在 C# 中,如何将刷新/重绘消息发送到 WPF 网格或画布?)
问题描述
如何向 WPF 网格或画布发送刷新消息?
How do you send a refresh message to a WPF grid or canvas?
换句话说,我注意到在调试模式下,我可以编写代码将一行发送到显示器,然后,如果该行不正确,我可以调整它——但前一行仍然存在.现在,我正在编写的代码根据用户点击的内容向显示器发送信息.所以这一定意味着每次新的一组行和框以及文本进入 WPF 中的网格或画布时,都不会刷新显示.
In other words, I have noticed while in debug mode, I can write code that sends a line to the display and then, if that line is not right, I can adjust it -- but the previous line is still there. Now, the code I am writing sends information to the display based on what the user clicks. So this must mean that the display is not refreshed each time a new set of lines and boxes and text goes to the grid or canvas in WPF.
使用 C# 代码,如何将刷新/重绘消息发送到 WPF 网格或画布?
Using C# code, how do you send a refresh/repaint message to a WPF grid or canvas?
推荐答案
刷新更新 Winforms 等 WPF 控件
public static class ExtensionMethods
{
private static Action EmptyDelegate = delegate() { };
public static void Refresh(this UIElement uiElement)
{
uiElement.Dispatcher.Invoke(DispatcherPriority.Render, EmptyDelegate);
}
}
这篇关于在 C# 中,如何将刷新/重绘消息发送到 WPF 网格或画布?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 C# 中,如何将刷新/重绘消息发送到 WPF 网格或画布?


基础教程推荐
- 将 XML 转换为通用列表 2022-01-01
- 如何在 IDE 中获取 Xamarin Studio C# 输出? 2022-01-01
- rabbitmq 的 REST API 2022-01-01
- SSE 浮点算术是否可重现? 2022-01-01
- 将 Office 安装到 Windows 容器 (servercore:ltsc2019) 失败,错误代码为 17002 2022-01-01
- MS Visual Studio .NET 的替代品 2022-01-01
- c# Math.Sqrt 实现 2022-01-01
- 如何激活MC67中的红灯 2022-01-01
- 为什么Flurl.Http DownloadFileAsync/Http客户端GetAsync需要 2022-09-30
- 有没有办法忽略 2GB 文件上传的 maxRequestLength 限制? 2022-01-01