private void DisposePassWord(ref PasswordBox passwordBox)
 {
     //Clear the dependency properties of PasswordBox
     passwordBox.ClearValue(PasswordBox.PasswordProperty);
     passwordBox.ClearValue(PasswordBox.FontFamilyProperty);
     passwordBox.ClearValue(PasswordBox.FontSizeProperty);
     passwordBox.ClearValue(PasswordBox.ForegroundProperty);
     passwordBox.ClearValue(PasswordBox.VisibilityProperty);
 }
Ejemplo n.º 2
0
        public void SelectionForeground_Styled()
        {
            var brush = new SolidColorBrush(Colors.Red);
            var style = new Style(typeof(PasswordBox));

            style.Setters.Add(new Setter(PasswordBox.SelectionForegroundProperty, brush));

            var box = new PasswordBox {
                Style = style
            };

            Assert.AreSame(brush, box.SelectionForeground, "#1");
            TestPanel.Children.Add(box);
            Assert.AreSame(brush, box.SelectionForeground, "#2");
            box.UpdateLayout();
            Assert.AreSame(brush, box.SelectionForeground, "#3");
            Enqueue(() => {
                Assert.AreSame(brush, box.SelectionForeground, "#4");
                Assert.IsUnset(box, PasswordBox.SelectionForegroundProperty, "#5");
            });
            Enqueue(() => {
                box.ClearValue(PasswordBox.SelectionForegroundProperty);
                Assert.AreSame(brush, box.SelectionForeground, "#6");
            });
            EnqueueTestComplete();
        }
Ejemplo n.º 3
0
        public void SelectionForeground()
        {
            var box = new PasswordBox();

            Assert.IsNull(box.SelectionForeground, "#1");
            TestPanel.Children.Add(box);
            Assert.IsNull(box.SelectionForeground, "#2");
            box.UpdateLayout();
            Assert.IsNull(box.SelectionForeground, "#3");
            Enqueue(() => { });
            Enqueue(() => {
                Assert.IsNotNull(box.SelectionForeground, "#4");
                Assert.IsUnset(box, PasswordBox.SelectionForegroundProperty, "#5");
            });
            Enqueue(() => {
                box.ClearValue(PasswordBox.SelectionForegroundProperty);
                Assert.IsNull(box.SelectionForeground, "#6");
            });
            EnqueueTestComplete();
        }
        //Метод, убирающий красные рамки с текстбоксов
        private void tb_GotFocus(object sender, RoutedEventArgs e)
        {
            if (sender is PasswordBox)
            {
                PasswordBox text_box = (PasswordBox)sender;
                text_box.ClearValue(BorderBrushProperty);
                text_box.BorderThickness = new Thickness(1);

                foreach (object child in grid_layout.Children)
                {
                    if (!(child is Label))
                    {
                        continue;
                    }

                    if (((Label)child).Tag != null && text_box.Tag != null && ((Label)child).Tag.ToString() == text_box.Tag.ToString())
                    {
                        ((Label)child).Visibility = Visibility.Hidden;
                    }
                }
            }
            else
            {
                TextBox text_box = (TextBox)sender;
                text_box.ClearValue(BorderBrushProperty);
                text_box.BorderThickness = new Thickness(1);

                foreach (object child in grid_layout.Children)
                {
                    if (!(child is Label))
                    {
                        continue;
                    }

                    if (((Label)child).Tag != null && text_box.Tag != null && ((Label)child).Tag.ToString() == text_box.Tag.ToString())
                    {
                        ((Label)child).Visibility = Visibility.Hidden;
                    }
                }
            }
        }