c# - 在 View 模型中访问密码框内容以验证登录

标签 c# wpf visual-studio-2010 mvvm

就像标题所说的一样。似乎只能在文件背后的代码中访问密码内容,但是如何将其传递到 View 模型中呢?

这仅用于基本的WPF登录屏幕,安全性不是最重要的问题。但是,我们仍然希望使用PW框控件。

谢谢

最佳答案

通常我只是通过PasswordBox将整个LoginCommand对象传递给CommandParameter

<Button Command="{Binding Path=LoginCommand}"
        CommandParameter="{Binding ElementName=MyPasswordBox}" ... />

然后,我可以将该对象转换为PasswordBox,并从PasswordBox.Password获取值

关于c# - 在 View 模型中访问密码框内容以验证登录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12973287/

相关文章:

c# - "ConnectionId"中不存在属性 "http://schemas.microsoft.com/winfx/2006/xaml"

c# - 粗体 TreeView 节点被截断 - 官方修复将不起作用,因为构造函数中的代码

c# - UTF8 文件开头字符正在破坏序列化器和读取器

c# - Base64图片转WPF图片源错误 No imaging component suitable

c# - 使用 Microsoft SDK 或 ManagementObjectSearcher 确定 Kinect 是否已插入

c# - Visual Studio 2010 - 无法单步执行 .NET Framework 4 源 (PresentationCore.dll)

visual-studio-2010 - Notepad++ 构建失败,并显示消息 PostBuildEvent : The system cannot find the file specified

visual-studio-2010 - 带有脚本的 SSIS 包无法升级到 VSTA - 如何修复或解决?

c# - 从确认框获取值

c# - 为什么我的File.Move()无法正常工作?