I am attempting to create a TextBox
that only allows numeric characters and a decimal point. I don't need assistance in writing the code, but on the concept. I am using MVVM
to design the WPF
application and I'm not sure whether to use an event or event-to-command.
I have read several different viewpoints regarding this topic:
- (I have found this to be a little extreme and as some have called it "counter-productive", but it upholds the "purity" of
MVVM
): Never have any code behind yourView
. To prevent this, use MVVM Light Library. In short, convert events to commands so that everything can be controlled in theViewModel
. - (The second argument does not uphold the (maybe over excessive) "purity" of
MVVM
): Not everything must be handled in theViewModel
and it is ok to createEvents
to handle certainUI
requirements.
I was leaning more towards the second option because of simplicity and, as I have stated previously, the first option seems a little extreme. In my specific case (creating a numeric only TextBox
) would most people prefer either of the above options or one I have not discovered?