How to bind to a PasswordBox in MVVM

前端 未结 30 1721
执念已碎
执念已碎 2020-11-22 11:50

I have come across a problem with binding to a PasswordBox. It seems it\'s a security risk but I am using the MVVM pattern so I wish to bypass this. I found som

30条回答
  •  囚心锁ツ
    2020-11-22 12:16

    
        
            
                
            
            
                
                    
                
                
                    
                
                
    
            
        
    

    using System;
    using System.Windows;
    using System.Windows.Controls;
    using Caliburn.Micro;
    
    namespace Elections.Server.Handler.ViewModels
    {
        public class LoginViewModel : PropertyChangedBase
        {
            MainViewModel _mainViewModel;
            public void SetMain(MainViewModel mainViewModel)
            {
                _mainViewModel = mainViewModel;
            }
    
            public void Login(Object password)
            {
                var pass = (PasswordBox) password;
                MessageBox.Show(pass.Password);
    
                //_mainViewModel.ScreenView = _mainViewModel.ControlPanelView;
                //_mainViewModel.TitleWindow = "Panel de Control";
                //HandlerBootstrapper.Title(_mainViewModel.TitleWindow);
            }
        }
    }

    ;) easy!

提交回复
热议问题