在C#中,如何将刷新/重绘消息发送到WPF网格或画布? [英] In C#, how do you send a refresh/repaint message to a WPF grid or canvas?

查看:134
本文介绍了在C#中,如何将刷新/重绘消息发送到WPF网格或画布?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



换句话说,我在调试模式下注意到了,我可以编写发送给WPF网格或画布的代码一行显示,然后,如果该行不正确,我可以调整它 - 但上一行仍然存在。
现在,我正在编写的代码会根据用户点击的内容向显示器发送信息。所以这必定意味着每当一组新的线条和框和文本进入WPF的网格或画布时,显示不会被刷新。

使用C#代码,如何使用C#代码你发送一个刷新/ repaint消息到WPF网格或画布?

解决方案

刷新更新像Winforms一样的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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆