ViewModel:
public class MyViewModel
{
[Required, StringLength(50)]
public String SomeProperty { ... }
}
XAML:
While I'm not going to write the code out completely myself, one idea is to create your own MarkupExtension that will take the property name and reflect over looking for a StringLengthAttribute.
If the attribute exists, attempt to bind the target to that value (using reflection). If not, then bind 0 to the target value (0 is default, i.e. no max).