在C#中,如何将刷新/重绘消息发送到WPF网格或画布? [英] In C#, how do you send a refresh/repaint message to a WPF grid or canvas?
问题描述
换句话说,我在调试模式下注意到了,我可以编写发送给WPF网格或画布的代码一行显示,然后,如果该行不正确,我可以调整它 - 但上一行仍然存在。
现在,我正在编写的代码会根据用户点击的内容向显示器发送信息。所以这必定意味着每当一组新的线条和框和文本进入WPF的网格或画布时,显示不会被刷新。
public static class ExtensionMethods
{
private static Action EmptyDelegate = delegate(){};
public static void Refresh(this UIElement uiElement)
{
uiElement.Dispatcher.Invoke(DispatcherPriority.Render,EmptyDelegate);
}
}
How do you send a refresh message to a WPF grid or canvas?
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.
Using C# code, how do you send a refresh/repaint message to a WPF grid or canvas?
Refresh update WPF Controls like Winforms
public static class ExtensionMethods
{
private static Action EmptyDelegate = delegate() { };
public static void Refresh(this UIElement uiElement)
{
uiElement.Dispatcher.Invoke(DispatcherPriority.Render, EmptyDelegate);
}
}
这篇关于在C#中,如何将刷新/重绘消息发送到WPF网格或画布?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!