WPF Maskedtextbox (Sfmaskededit) – Getting Started Demo

Sample date Updated on Apr 02, 2026
box mask mask-edit maskedit maskedtextbox sfmask-edit syncfusion text tools wpf

This sample shows how to add and use the Syncfusion WPF MaskedTextBox (SfMaskedEdit) to constrain and format user input. It demonstrates simple and RegEx masks, value formatting, prompt characters, watermark, validation modes, and theming so you can reliably capture structured data like dates, phone numbers, and IDs.

Features

  • Simple and RegEx mask types to restrict input
  • Predefined mask elements and custom patterns
  • Value formatting via ValueMaskFormat (Exclude/Include prompt and literals)
  • Prompt character customization and show-on-focus option
  • Validation modes: on key press or on lost focus
  • Error indication with configurable error border brush
  • Watermark text and custom watermark template
  • ValueChanged event notification
  • Built-in theme support via SfSkinManager

Usage Tips

  • Use MaskType="RegEx" for flexible validation with look-ahead/negation groups.
  • Choose ValueMaskFormat to control whether prompt/literals are included in Value.
  • Set PromptChar to guide users and enable ShowPromptOnFocus to display placeholders on focus.
  • Switch ValidationMode to LostFocus for relaxed typing, or KeyPress for immediate feedback.
  • Customize ErrorBorderBrush to align with your app’s error styling.
  • Provide Watermark to communicate expected format when empty.
  • Handle ValueChanged to react to valid changes (e.g., enable submit, trigger lookup).
  • Apply themes globally with SfSkinManager for a polished look.

Basic Mask Ideas (RegEx)

  • Positive or negative integers: -?\d+
  • Decimal numbers: -?\d+.?\d*
  • Phone: ([0-9]\d{2}) [0-9]\d{2}-[0-9]\d{3}
  • Email: [A-Za-z0-9._%-]+@[A-Za-z0-9]+.[A-Za-z]{2,3}
  • Time (24h): (0[0-9]|1[0-9]|2[0-3]):[0-5][0-9]
  • Hex color: #[A-Fa-f0-9]{6}

About the Sample

This repository includes focused examples that map to common scenarios:

  • Samples/Getting-Started – minimal setup for SfMaskedEdit
  • Samples/InputOptions – value formats, validation modes, prompts, watermark
  • Samples/BasicMasks – a collection of practical mask patterns
  • Samples/Appearance and Samples/Themes – visual customization and theming

Use these as a starting point to capture structured input consistently across your app.

Up arrow