【发布时间】:2021-03-22 21:03:24
【问题描述】:
我使用 Visual Studio 创建了一个 GUI,并在 Powershell 中导入了 XAML 代码,但在文本框中显示来自 5 个组合框选定项之一的值时遇到问题。 我自己学习,我真的很喜欢它,但我没有单独调试代码的好方法, 任何人都可以有时间和知识来帮助我吗?
我想在文本框 ($TxtBox) 中显示来自 CboPL 或 CboTG 或 CboSB 的选定项目(或值)...。 使用 powershell。
这是我的 XAML 代码 beetwen here in powershell 中的字符串:
<Window x:Name="Main" x:Class="Printers_Ordi.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:Printers_Ordi"
mc:Ignorable="d"
Title="Printers-Ordi" Height="450" Width="728.471">
<Grid x:Name="Wall">
<Grid.Background>
<ImageBrush ImageSource="C:/Users/admsb160365/Desktop/scripts Shell/Imprimantes GHT/Wall.png"/>
</Grid.Background>
<Label x:Name="LabelTitre" Content="Printers-Ordi" HorizontalAlignment="Left" Margin="74,25,0,0" VerticalAlignment="Top" FontFamily="Yu Gothic UI Semibold" FontSize="24" RenderTransformOrigin="0.503,0.76" Height="42" Width="164" Foreground="#FF1346CD"/>
<ComboBox x:Name="CboComputer" HorizontalAlignment="Left" Margin="74,82,0,0" VerticalAlignment="Top" Width="164" FontSize="16" Height="31" IsEditable="True" IsReadOnly="True" Text="Ordinateur"/>
<ComboBox x:Name="CboSites" HorizontalAlignment="Left" Margin="74,118,0,0" VerticalAlignment="Top" Width="164" Height="31" FontSize="16" IsEditable="True" IsReadOnly="True" Text="Sites">
<ComboBox x:Name="CboPL" HorizontalAlignment="Left" VerticalAlignment="Top" Width="154" FontSize="16" IsEditable="True" IsReadOnly="True" Text="Paimpol"/>
<ComboBox x:Name="CboGP" HorizontalAlignment="Left" VerticalAlignment="Top" Width="154" FontSize="16" IsEditable="True" IsReadOnly="True" Text="Guingamp"/>
<ComboBox x:Name="CboSB" HorizontalAlignment="Left" VerticalAlignment="Top" Width="154" FontSize="16" IsEditable="True" IsReadOnly="True" Text="SaintBrieuc"/>
<ComboBox x:Name="CboLN" HorizontalAlignment="Left" VerticalAlignment="Top" Width="154" FontSize="16" IsEditable="True" IsReadOnly="True" Text="Lannion"/>
<ComboBox x:Name="CboTG" HorizontalAlignment="Left" VerticalAlignment="Top" Width="154" FontSize="16" IsEditable="True" IsReadOnly="True" Text="Treguier"/>
</ComboBox>
提前感谢您的耐心和支持 ;-)
【问题讨论】:
-
您将使用条件逻辑来检查这些框中是否有文本,从这些组合框中收集/捕获 .text 值,并将该文本放置在表单元素的 .text 值中你需要它的地方。关于 WinForms/WPF 和 Combobox 用例,网络和 Youtube 上都有很多例子。
标签: powershell xaml combobox textbox display