In C#, how do you send a refresh/repaint message to a WPF grid or canvas?

蓝咒 提交于 2019-11-30 05:48:15

问题


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?


回答1:


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);
   }
}



回答2:


I'm used to winforms so this is only a guess, but look for an Invalidate() method.



来源:https://stackoverflow.com/questions/2886532/in-c-how-do-you-send-a-refresh-repaint-message-to-a-wpf-grid-or-canvas

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!