From 32601d164ab628cba07a4653a6d83951d3a300ab Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Sat, 22 Oct 2016 18:43:21 +0200 Subject: [PATCH] fixes a null ref --- BookAStar/BookAStar/Behaviors/MaxLengthValidator.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/BookAStar/BookAStar/Behaviors/MaxLengthValidator.cs b/BookAStar/BookAStar/Behaviors/MaxLengthValidator.cs index 07f51476..5c460345 100644 --- a/BookAStar/BookAStar/Behaviors/MaxLengthValidator.cs +++ b/BookAStar/BookAStar/Behaviors/MaxLengthValidator.cs @@ -26,8 +26,8 @@ namespace BookAStar.Behaviors private void bindable_TextChanged(object sender, TextChangedEventArgs e) { - IsValid = e.NewTextValue.Length <= 0 || e.NewTextValue.Length <= MaxLength; - if (!IsValid && e.NewTextValue.Length > MaxLength) + IsValid = e.NewTextValue == null? false : ( e.NewTextValue.Length > 0 && e.NewTextValue.Length <= MaxLength ) ; + if (!IsValid) if (e.NewTextValue!=null) if (e.NewTextValue.Length > MaxLength) ((Editor)sender).Text = e.NewTextValue.Substring(0, MaxLength); }