Home > Software engineering >  How to interrogate GUI controls in a WPF application?
How to interrogate GUI controls in a WPF application?

Time:09-17

Still setting my first steps in WPF, this time I'm dealing with this "simple" situation:

dt_Proposal.Rows[0].ItemArray[i] = highest_val   min_val;

This piece of code has been run for every value of i (also for value 2), so I expect to see something on the place of the red rounded rectangle:

enter image description here

However I don't see any value there.

I decided to pauze my application (Visual Studio "Debug" menu, "Break All" menu item), and then I thought of having a look at the controls of my form, but how?

Visual Studio's "Locals" window contains this, which is mentioned being a <Application_Name>.MainWindow, but I can't look deeper.
When adding this to the "Watchlist", this seems not even to be accessible.

So this becomes a very general question: I am working on the GUI of a WPF application, and I would like to see the properties/fields of the controls/GUI components of my main form, and I would like to do this while my application is waiting on any kind of user input (typical "wait state" for a GUI application).
How can I do that?

CodePudding user response:

In WPF you can see Visual Tree (even without pausing the app at all!), you enter this like shown in below picture:

enter image description here

By the way, value hello world was set programatically:

private void Button_Click(object sender, RoutedEventArgs e)
{
    txtInfo.Text = "hello world";
}

Once in Visual Tree, you can right click control and show its properties: enter image description here

And there you can see values of properties set: enter image description here

  • Related