/// <summary>
        /// Invoked whenever application code or internal processes (such as a rebuilding layout pass) call ApplyTemplate. In simplest terms, this means the method is called just before a UI element displays in your app. Override this method to influence the default post-template logic of a class.
        /// </summary>
        protected override void OnApplyTemplate()
        {
            base.OnApplyTemplate();
            _innerPasswordBox = (PasswordBox)GetTemplateChild(InnerPasswordBoxName);
            _innerPasswordBox.PasswordChanged += InnerPasswordBoxOnPasswordChanged;
            _innerPasswordBox.KeyUp += InnerPasswordBoxOnKeyUp;
            _innerPasswordBox.GotFocus += InnerPasswordBoxOnGotFocus;
            _innerPasswordBox.LostFocus += InnerPasswordBoxOnLostFocus;
            _innerPasswordBox.ContextMenuOpening += InnerPasswordBoxOnContextMenuOpening;

            _innerPasswordBox.SetBinding(
                PasswordBox.PasswordProperty,
                new Binding
                {
                    Path = new PropertyPath("Password"),
                    Mode = BindingMode.TwoWay,
                    Source = this
                });
            _innerPasswordBox.SetBinding(
                PasswordBox.PasswordCharProperty,
                new Binding
                {
                    Path = new PropertyPath("PasswordChar"),
                    Mode = BindingMode.TwoWay,
                    Source = this
                });
            _innerPasswordBox.SetBinding(
                PasswordBox.PasswordRevealModeProperty,
                new Binding
                {
                    Path = new PropertyPath("PasswordRevealMode"),
                    Mode = BindingMode.TwoWay,
                    Source = this
                });
            _innerPasswordBox.SetBinding(
                PasswordBox.MaxLengthProperty,
                new Binding
                {
                    Path = new PropertyPath("MaxLength"),
                    Mode = BindingMode.TwoWay,
                    Source = this
                });

            UpdateWatermarkVisualState(false, false);
        }