1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
[xml]$xaml = @" <Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Name="Window" Title="Ventana" WindowStartupLocation = "CenterScreen" Width = "500" Height = "500" ShowInTaskbar = "True"> <Button x:Name = "Botón" Height = "100" Width = "100" ToolTip = "This is a button"> </Button> </Window> "@ $reader = (New-Object System.Xml.XmlNodeReader $xaml) $Window = [Windows.Markup.XamlReader]::Load($reader) # Conectar con el control de XAML $button = $Window.FindName("Botón") $button.AddText("Botón") # Hacer click y cambiar el fondo $button.Add_Click({ $Window.Background = (Get-Random -InputObject "Black","Red","White") }) $Window.ShowDialog() | Out-Null |
