-
Notifications
You must be signed in to change notification settings - Fork 74
/
Copy pathValidationTextBox.cs
executable file
·42 lines (38 loc) · 1.36 KB
/
ValidationTextBox.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
//
// This is the source code of Telegram for Windows Phone v. 3.x.x.
// It is licensed under GNU GPL v. 2 or later.
// You should have received a copy of the license in this archive (see LICENSE).
//
// Copyright Evgeniy Nadymov, 2013-2018.
//
using System.Windows;
using System.Windows.Controls;
namespace Telegram.Controls
{
public class ValidationTextBox : TextBox
{
public ValidationTextBox()
{
DefaultStyleKey = typeof(ValidationTextBox);
}
public static readonly DependencyProperty HasErrorProperty = DependencyProperty.Register(
"HasError", typeof (bool), typeof (ValidationTextBox), new PropertyMetadata(default(bool), OnHasErrorChanged));
private static void OnHasErrorChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var validationTextBox = (ValidationTextBox)d;
if ((bool)e.NewValue)
{
VisualStateManager.GoToState(validationTextBox, "Invalid", true);
}
else
{
VisualStateManager.GoToState(validationTextBox, "Valid", true);
}
}
public bool HasError
{
get { return (bool) GetValue(HasErrorProperty); }
set { SetValue(HasErrorProperty, value); }
}
}
}