Here is the code:
new FrameworkPropertyMetadata( (uint) 100,...
We can set in max value here as 100, is there a way to set minimum value too? Let’s say I want this default value to be between 5 and 100? I looked all over Google did not find any answers. Can anybody please suggest a solution. Thanks!
Code tried according to Reed Copsey
public static bool IsValidReading(object value)
{
uint v = (uint)value;
return (!v.Equals(0));
}
Full code:
public static readonly DependencyProperty Result =
DependencyProperty.Register(
"ResultLimit", typeof( uint ), typeof( UI ),
new FrameworkPropertyMetadata( ( uint )10, new PropertyChangedCallback( ResultChanged ) ), IsValidReading );
The value is not the max value – it’s the default value.
There is no way to specify the min or max in the metadata directly. This should be handled via a Callback registered with the Dependency Property.