Visualize object properties in a WPF control

Is it possible to visualize an object (its properties together with their values) and print it (reset - like serialization) into a WPF control, such as a TreeView or PropertyGrid, to validate the object?

The goal is to display the contents of any arbitrary object (not just for debugging purposes).

For further clarification: I'm not looking for any debugging tools or ways to display the WPF visual tree. This question is partially related to WPF -> WPF - this is only the environment for displaying an object dump, since the controls may differ between WPF and WinForms.

The result should be hierarchical for instances of nested objects, lists, etc.

Object visualization

+6
source share
6 answers

I think you should take a look at Snoop

This program will allow you to navigate the WPF tree of any running application. No debugging is required for this tool, and the tool may not work with debugging. I usually use it in non-debugging scripts to see how my WPF controls actually set up and what values ​​they have for various properties.

+5
source

I believe you are looking for System.Diagnostics.DebuggerDisplayAttribute

+2
source

You mean besides WPF Tree Visualizer? There is Mole , which is no longer free, but very good.

Edit:

Reading an editable question. You explicitly call PropertyGrid, I suppose you've already tried the Extended WPF Toolkit PropertyGrid ?

+2
source

So, you need a control that displays the class field at runtime. You will find many articles about this by looking for the “Property Grid”. This is not what you want, but the beginning. You basically iterate through the reflection over the fields of the class and display them in a ListView / TreeView. But it was a difficult beginning, determining which fields to show and which to hide, process with different types and primitives and allow editing them with type conversion (for example, a line in Rect, point, color, etc.) - this is a very difficult question. This control can give you a good starting point.

0
source

There are various existing controls that let you view properties as a Property Grid.

http://www.codeproject.com/Articles/87715/Native-WPF-4-PropertyGrid

https://wpftoolkit.codeplex.com/wikipage?title=PropertyGrid

https://wpg.codeplex.com/

Depending on the complexity, license and features that they represent, you will need to choose one, they will all be free.

0
source

I have been looking for an answer for this for several months; Snoop, Spy and everyone else did not work for me due to violations of ownership of the threads.

Microsoft has a tool for Windows that allows you to select any running UI element and view the element’s accessibility data:

 inspect.exe 

https://msdn.microsoft.com/en-us/library/dd318521(VS.85).aspx

It is available in the Windows software development kits that you need to download and install, and is located in:

 C:\Program Files\x86\(win-version)\bin\(cpu-architecture)\inspect.exe 
0
source

Source: https://habr.com/ru/post/950660/


All Articles