Text Input Controls: Entry and Editor
Entry is MAUI's single-line text input control, exposing Keyboard (Keyboard.Numeric, Keyboard.Email, Keyboard.Telephone, etc.) to hint the platform's on-screen keyboard layout, IsPassword to mask characters, and ReturnType/ReturnCommand to customize and handle the keyboard's action button, while Editor is its multi-line counterpart used for longer free-form text like comments or notes, both exposing a two-way bindable Text property and TextChanged/Completed events.
Cricket analogy: Keyboard.Numeric hinting a numeric keypad is like an umpire's hand signal automatically cueing the scorer to expect a run-count entry rather than a wide or no-ball note.
Gestures and GestureRecognizers
Beyond typed text, MAUI captures input through GestureRecognizers attached to any View's GestureRecognizers collection: TapGestureRecognizer (with NumberOfTapsRequired for double-tap), PanGestureRecognizer for drag tracking, PinchGestureRecognizer for pinch-to-zoom, and SwipeGestureRecognizer with a Direction property (Left, Right, Up, Down), each exposing events or Command bindings so a plain Image or BoxView can become as interactive as a dedicated Button.
Cricket analogy: SwipeGestureRecognizer's Direction property is like a fielder diving in a specific direction, Left or Right, to intercept a shot — the gesture only fires when motion matches the declared direction, just as a dive only succeeds toward the ball's actual path.
<Image Source="card_back.png" WidthRequest="240" HeightRequest="140">
<Image.GestureRecognizers>
<TapGestureRecognizer NumberOfTapsRequired="2" Command="{Binding FlipCardCommand}" />
<SwipeGestureRecognizer Direction="Left" Command="{Binding DismissCommand}" Threshold="80" />
</Image.GestureRecognizers>
</Image>
<Entry Placeholder="Enter amount" Keyboard="Numeric"
Text="{Binding Amount, Mode=TwoWay}"
ReturnType="Done" ReturnCommand="{Binding SubmitCommand}" />Validation and Input Constraints
Input validation in MAUI is typically handled in the ViewModel rather than the view — binding Entry.Text with Mode=TwoWay and validating on PropertyChanged, or using behaviors like the community toolkit's TextValidationBehavior with a regex Pattern, MinimumLength, and MaximumLength to enforce constraints and toggle visual feedback such as a red border color or an error Label, since MAUI has no built-in validation framework equivalent to WPF's IDataErrorInfo out of the box.
Cricket analogy: Validating Entry.Text in the ViewModel on PropertyChanged is like a third umpire continuously reviewing a batsman's foot position for a stumping the instant new frame data arrives, rather than waiting until the over ends.
Avoid running expensive or blocking validation logic directly inside a TextChanged event handler in code-behind — it fires on every keystroke and runs on the UI thread. Debounce validation (e.g., only validate after typing pauses) or keep checks lightweight, and prefer ViewModel-bound validation so the logic is testable outside the view.
- Entry is single-line, Editor is multi-line, both expose two-way bindable Text
- Keyboard property hints (Numeric, Email, Telephone) tailor the on-screen keyboard
- GestureRecognizers (Tap, Pan, Pinch, Swipe) add interactivity to any View
- SwipeGestureRecognizer's Direction property detects Left/Right/Up/Down swipes
- MAUI has no built-in validation framework; use ViewModel logic or toolkit behaviors
- TextValidationBehavior supports regex Pattern, MinimumLength, and MaximumLength
- ReturnCommand handles the keyboard's action button declaratively
Practice what you learned
1. Which control is best suited for multi-line free-form text like comments?
2. Which property hints the platform keyboard to show a numeric layout?
3. Which GestureRecognizer detects a two-finger zoom motion?
4. What property on SwipeGestureRecognizer specifies the required swipe direction?
5. Where is input validation logic typically implemented in a MAUI MVVM app?
Was this page helpful?
You May Also Like
Common Controls
A tour of MAUI's core display and interactive controls — Label, Button, CollectionView, Switch, and progress indicators — and the patterns that make them MVVM-friendly.
MAUI Layouts
How Grid, StackLayout, FlexLayout, and AbsoluteLayout measure and arrange child views, and when to choose each for performance and responsiveness.
Styling and Resources
How ResourceDictionary scoping, implicit/explicit Styles, BasedOn inheritance, and AppThemeBinding/DynamicResource combine to theme a MAUI app.
Related Reading
Related Study Notes in Programming
Browse all study notesApache Spark Study Notes
Programming · 30 topics
ProgrammingApache Flink Study Notes
Programming · 30 topics
ProgrammingHadoop Study Notes
Programming · 30 topics
ProgrammingSnowflake Study Notes
Programming · 30 topics
ProgrammingApache Airflow Study Notes
Programming · 30 topics
Programmingdbt (Data Build Tool) Study Notes
Programming · 30 topics