System.ComponentModel.DataAnnotations.RangeAttribute does not have any effect

Grids for WPF Forum

Posted 4 years ago by Neil Larson
Version: 15.1.0623
Avatar

I have created a property (see below) that shows ok in the grid, but am having trouble getting it to validate against the provided range. Is there a way to enforce the range in the property grid?


private int _Cue;
[DisplayName("Cue")]
[Category("General")]
[Description("Cue to lockout")]
[Range(1, 48)]
public int Cue
{
get
{
return _Cue;
}
set
{
if(_Cue == value)
return;

_Cue = value;
RaisePropertyChanged(() => Cue);
}
}

Thanks,

Neil

Comments (1)

Posted 4 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Neil,

Sorry but we don't handle that attribute.  But what you could do is use our Int32EditBox in your PropertyGrid value template, and give the edit box a Minimum and Maximum based on your needs.  That would give a nice UI for the property and would restrict it to the desired range.


Actipro Software Support

The latest build of this product (v2019.1 build 0683) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.