winrt maxlength spellcheck conflict

46 Views Asked by At

In a WinRT XAML form I define a MaxLength and also enable spellcheck-

<TextBox 
   Text="{Binding Description, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" 
   IsSpellCheckEnabled="True" 
   MaxLength="255" 
   TextWrapping="Wrap" 
   IsTextPredictionEnabled ="True" 
   PlaceholderText="Description" 
   AcceptsReturn="False" 
   Foreground="Black" 
   BorderBrush="Gray" 
   FontSize="22"/>

Although MaxLength happily works when typing directly in, yet there is a bug.

For example, if the last word gets truncated, eg: 'studies' becomes 'studie' due to lack of space, then spell check highlights 'studie' and allows you to select the correct spelling 'studies'.

No max length check is done and the length of the text in the control exceeds MaxLength. This does not impress the back-end when the data is presented longer than expected.

What I am looking for is a way to handle this in all the fields with a minimum of code. I can certainly fix the view model for each field in the property set but was hoping to find a better way.

All suggestions greatly appreciated and spellchecked free of charge!

1

There are 1 best solutions below

0
On

No takers? I can't really see an answer to this one. Some approaches-

  • Have a TextBoxVM and instantiate using property name and length passed in from parent VM. Pass length into XAML control maxlength. Use the length to check when data is set then truncate if over.
  • Implement each VM Property as normal but include a maxlength property in the VM for the maxlength text property that then is reused to recheck the length when the property is set.

Bottom line - Get spellcheck for free? Nothing is free.