You can use these XAML tools even when you don't have the source code. The MainWindow.xaml file opens in Visual Studio and the cursor is placed on the line where the button is defined. Select Enable selection and Preview selection, and then you select the button in our test application.
This mode shows the XAML where the element was declared, if you have access to the source code of the application. You can enable this mode by selecting the third button from the left on the Live Visual Tree toolbar. You should see the text block node in the Live Visual Tree and the text block properties in the Live Property Viewer, as well as the horizontal and vertical lines on the bounds of the text block. For example, turn both Enable selection and Display layout on, and select the Add Item text block in the application.
When Display layout adorners is on, it causes the application window to show horizontal and vertical lines along the bounds of the selected object so you can see what it aligns to, as well as rectangles showing the margins. You can enable this mode when you select the button that is immediately to the right of the Enable selection button. With this mode on, you can select a UI element in the application, and the Live Visual Tree (and the Live Property Viewer) automatically updates to show the node in the tree corresponding to that element, and its properties.ĭisplay layout adorners in the running application. You can enable this mode when you select the leftmost button on the Live Visual Tree toolbar. The MainWindow.xaml file opens in Visual Studio and the cursor is placed on the line where the button is defined.Įnable selection in the running application. Select Select element and Preview selection, and then you select the button in our test application. For example, turn both Select element and Display layout on, and select the Add Item text block in the application. Starting in Visual Studio 2019 version 16.4, you can configure the behavior of element selection.ĭisplay layout adorners in the running application. With this mode on, you can select a UI element in the application, and the Live Visual Tree (and the Live Property Viewer) automatically updates to show the node in the tree corresponding to that element, and its properties.
Select element in the running application. When the window comes up you should see the in-app toolbar appear within your running application. For more information about build configurations, see Understanding Build Configurations.) (The build configuration must be Debug, not Release. Private void button_Click(object sender, RoutedEventArgs e)īuild the project and start debugging.
Name it TestXAML.Ĭhange MainWindow.xaml to the following: Īdd the following command handler to the file: int count