private void InitializeComponent()
        {
            AvaloniaXamlLoader.Load(this);

            var textBox = this.FindControl <TextBox>("PasswordControl");

            this.PropertyChanged += (s, e) =>
            {
                if (e.Property == Control.DataContextProperty)
                {
                    PasswordControlViewModel dataContext = (PasswordControlViewModel)e.NewValue;

                    textBox.GetObservable(TextBox.SelectionStartProperty).Subscribe(position =>
                    {
                        if (dataContext != null)
                        {
                            dataContext.SelectionStart = position;
                        }
                    });

                    textBox.GetObservable(TextBox.SelectionEndProperty).Subscribe(position =>
                    {
                        if (dataContext != null)
                        {
                            dataContext.SelectionEnd = position;
                        }
                    });
                }
            };
        }
Example #2
0
 public CreateDerivedKeyPasswordViewModel()
 {
     PasswordVM             = new PasswordControlViewModel(PasswordChanged, "Password...");
     PasswordConfirmationVM = new PasswordControlViewModel(PasswordChanged, "Password confirmation...");
 }
Example #3
0
 public WriteDerivedKeyPasswordViewModel()
 {
     PasswordVM = new PasswordControlViewModel(placeholder: "Password...");
 }