Naming and locating controls
It is only possible to perform actions on controls in the UI if they can be located. None of the controls in the preceding examples have been given names. Locating one of the buttons in a StackPanel
, for example, is difficult as it stands.
Returning to the StackPanel
example, it has three buttons:
$xaml = [xml]'
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Width="350" Height="350">
'
$window = [System.Windows.Markup.XamlReader]::Load(
[System.Xml.XmlNodeReader]$xaml
)
Accessing the Text
property...