Powershell WPF密码箱获得价值

时间:2018-08-07 08:52:20

标签: wpf powershell xaml passwordbox

我猜我只是一个小问题。 我使用WPF为Powershell创建了一个GUI,该GUI中是一个密码箱,现在我想从此密码箱中获得一个明确的值到PS中的变量中。

<PasswordBox Name="PWBox" HorizontalAlignment="Left" Margin="147,75,0,0" VerticalAlignment="Top" Width="137" FontFamily="Century Gothic"/>

我测试了例如:

$password = $PWBox.Password

但是我在$ password中没有值

正确的方法是什么?

预先感谢, 罗宾

1 个答案:

答案 0 :(得分:0)

如果我们能看到代码就好了,否则答案可能会像问题一样模糊。 你可以试试

<PasswordBox x:Name="PWBox" HorizontalAlignment="Left" Margin="147,75,0,0" VerticalAlignment="Top" Width="137" FontFamily="Century Gothic"/>

然后你需要“告诉”WPF你想在PS中使用变量

$Script:password = $PWBox.Password

然后你应该可以在脚本中看到你的 $password 变量

相关问题