Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. WPF
  4. How do you send a refresh message to a WPF grid or canvas?

How do you send a refresh message to a WPF grid or canvas?

Scheduled Pinned Locked Moved WPF
csharpcsswpfdebuggingquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • X Offline
    X Offline
    Xarzu
    wrote on last edited by
    #1

    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?

    J 1 Reply Last reply
    0
    • X Xarzu

      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?

      J Offline
      J Offline
      Jurgen Rohr
      wrote on last edited by
      #2

      Hi, although I'm not sure about your saying "...code that sends a line to the display...", I'll try to answer, as far as I've understood: The "UIElement" class has a method "InvalidateVisual", which will force a complete new layout pass; Grid and Canvas derive from "UIElement" and thus have this method available. But this is a rather expensive (considering performance) way to 'refresh the screen'. If you have a TextBlock or TextBox for the "line" in your container (Grid or Canvas), you could give it a name (in the VS designer) and access the "Text" property from code. This would work just as in WinForms. This assumes, that you know your control at design time. The easiest and most WPF-like (and to me the only correct) way, is to bind the "Text" property of the textcontrol to a string property (say: MyText) of an object (say: class MyData) used as the container's "DataContext". The "MyData" class must implement the interface "INotifyPropertyChanged" and the "MyText" setter must fire the "PropertyChanged" event. Now every change to the "MyText" property will be automatically be reflected in the textcontrol. Hope this helps to get you on the right track. Cheers Jürgen

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups