screen 'data input' - masking made easy !?

Public forum to share code snippets, screen shorts, experiences, etc.
Post Reply
User avatar
Phil Hepburn
Posts: 743
Joined: Sun Sep 11, 2016 2:16 pm

screen 'data input' - masking made easy !?

Post by Phil Hepburn »

Hi guys,

Frank this is particularly for you, as you posted a little while ago about going over to new formatted screens, and hence input of data.

Well, I have just gotten my Cologne app on data validation in WPF/XAML to three quarters run in X#, the app I supplied to the conference last year was completely in C#. So lots of hand translating been going on in Wales, UK, these last couple of days.

One little part of the code and app made me think of you and your task, as well as all the post over the years crying over the lost VO facilities for screen input - it not being there any more, etc., etc., ...

Well, we do have some FREE and useful tools in WPF, free as we can code them ourselves, once we know how.

Let me give you a small taster (example) of a simple 'mask' which allows three alphabetic characters and after a 'dot' or point, three digits.

Between the Validation Rule approach, we also have 'Converters' that we can code and customise, as well as 'data binding' where different parts of what looks like the same input 'box' are in fact bound to different properties of the ViewModel.

Simpler things first - lets first of all see how simple this test code is :-
Masking_01.jpg
Masking_01.jpg (114.39 KiB) Viewed 258 times
And then the single line of XAML script to associate the Validation Rule with the 'TextBox' control :-
Masking_02.jpg
Masking_02.jpg (62.34 KiB) Viewed 258 times
Don't worry about the test code/script, I do realise that I am using the email box for testing the mask out ;-0)

Now then - how about a video clip to show you this simple mask in action ? Check this out :-

[The extension mp4 has been deactivated and can no longer be displayed.]

Now then folks, I hear Karl and others saying that the dot (or point) should be fixed and not have to be typed in - well that comes later with some splitting up of the mask into three parts (visually the user will not know of this) the parts will be a text input box for the three characters, a fixed text block with the point, and then another text input box for the three digits. All together looking as one!

The bindings are on the input boxes - public properties of the ViewModel bound to the first and third boxes.

In fact, while we are having fun, I can make a test app for us where we can change the RegEx masking string in 'real time', from a combo box. SO we can switch on different masks, like magic.

This is just to show you that we can control and validate input to be almost anything we care to choose - we just have to do it a different way, that all. New, different.

I will get on with designing a more complex and flexible masking sample.

Regards for now, 
Phil.
Wales, UK.
Frank Maraite
Posts: 178
Joined: Sat Dec 05, 2015 10:44 am
Location: Germany

screen 'data input' - masking made easy !?

Post by Frank Maraite »

Hi Phil,

thanks for showing that. I still did not work on this but will do the next weeks.
I found an similar solution but for WinForms. It had a textbox for each position.

I know I have to deal with ValidationRules and ValueConverters. Just working on others things dealing with real big data (640MB zip with compression to 3%).

Will be back data enter soon.

Frank
Post Reply