PowerShell在事件上更新WPF窗口

时间:2018-09-10 20:20:35

标签: wpf powershell

我正在使用PowerShell构建WPF UI,以便用户(除其他事项外)可以指示是否应将NIC配置为使用DHCP或进行静态配置。我想要一个带有“ DHCP”和“静态”的组合框,或者两个按钮。

如果用户选择“静态”,那么我想更新窗口以显示“ IP”,“子网”和“网关”文本框。

我似乎找不到任何将新文本框和标签添加到现有窗口的方法。这是我拥有的XAML(显示IP配置字段应该在哪里)。我从这里去哪里?

<Window x:Class="WpfApplication1.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:WpfApplication1"
        mc:Ignorable="d"
        Title="IPMI Config Tool" Height="321.563" Width="421.361">
    <Grid HorizontalAlignment="Left" Width="415">
        <TextBlock x:Name="textBlock" Margin="10,10,145.907,0" TextWrapping="Wrap" VerticalAlignment="Top"><Run FontWeight="Bold" Text="Specify the IP config information for the IPMI port. If you click the Cancel button, you may not be prompted again."/></TextBlock>
        <Label x:Name="ipTypeLabel" Content="IP Config Type*" Margin="21,71,243,0" VerticalAlignment="Top"/>
        <ComboBox HorizontalAlignment="Left" Margin="21,100,0,0" VerticalAlignment="Top" Width="120">
            <ComboBoxItem Content="DHCP" HorizontalAlignment="Left" Width="118"/>
            <ComboBoxItem Content="Static" HorizontalAlignment="Left" Width="118"/>
        </ComboBox>
        <Label x:Name="ipLabel" Content="Static IPMI IP*" Margin="21,161,243,0" VerticalAlignment="Top"/>
        <TextBox x:Name="ipTxt" Height="26" Margin="177,161,82,0" TextWrapping="Wrap" VerticalAlignment="Top" ToolTip="Static IP for the IPMI port."/>
        <Label x:Name="maskLabel" Content="Static IPMI Subnet Mask*" Margin="21,188,111,0" VerticalAlignment="Top"/>
        <TextBox x:Name="maskTxt" Height="26" Margin="177,188,82,0" TextWrapping="Wrap" VerticalAlignment="Top" ToolTip="Static subnet mask for the IPMI port."/>
        <Label x:Name="gatewayLabel" Content="Static IPMI Gateway IP*" Margin="21,215,243,0" VerticalAlignment="Top"/>
        <TextBox x:Name="gatewayTxt" Height="26" Margin="177,215,82,0" TextWrapping="Wrap" VerticalAlignment="Top" ToolTip="Static gateway IP for the IPMI port."/>
        <Button x:Name="okButton" Content="OK" HorizontalAlignment="Left" Margin="18.928,0,0,10" VerticalAlignment="Bottom" Width="50" IsDefault="True"/>
        <Button x:Name="cancelButton" Content="Cancel" HorizontalAlignment="Left" Margin="80.317,0,0,10" VerticalAlignment="Bottom" Width="50" IsCancel="True"/>
    </Grid>
</Window>

0 个答案:

没有答案