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

前端 未结 2 1661
孤街浪徒
孤街浪徒 2021-01-06 02:07

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

2条回答
  •  说谎
    说谎 (楼主)
    2021-01-06 03:05

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

提交回复
热议问题