I have this code
我有这个代码
using System.Windows;
namespace TestWpfApplication
{
public partial class Window5 : Window
{
public Window5()
{
InitializeComponent();
}
public int XX
{
get { return (int)GetValue(XXProperty); }
set { SetValue(XXProperty, value); }
}
public static readonly DependencyProperty XXProperty =
DependencyProperty.Register("XX", typeof(int), typeof(Window5), new PropertyMetadata(1),ValidateXX);
private static bool ValidateXX(object value)
{
int? d =value as int?;
var res= d != null && d > 0 && d < 20;
return res;
}
}
}
using System.Windo