Articles in this section
Category / Section

How to customize the SfMaskedEdit with rounded corner in WPF?

1 min read

This article provides a step-by-step guide on customizing the WPF MaskedEdit control to achieve a polished appearance with rounded corners.

Step 1: Define a Custom Style

In your XAML resource section, define a custom SfMaskedEdit style with a unique key, such as “CustomMaskedEditStyle.” This style overrides the default template, allowing you to modify the corner radius of the border.

XAML

  <Window.Resources>
  <ResourceDictionary>
      <ResourceDictionary.MergedDictionaries>
          <ResourceDictionary Source="/Syncfusion.SfInput.WPF;component/Themes/Generic.xaml" />
      </ResourceDictionary.MergedDictionaries>

      <Style x:Key="CustomMaskedEditStyle" TargetType="syncfusion:SfMaskedEdit" BasedOn="{StaticResource MaskedEditStyle}">
          <Setter Property="Template">
              <Setter.Value>
                  <ControlTemplate TargetType="{x:Type syncfusion:SfMaskedEdit}">
                      <Border CornerRadius="10" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
                          <ScrollViewer x:Name="PART_ContentHost"/>
                      </Border>
                  </ControlTemplate>
              </Setter.Value>
          </Setter>
      </Style>
  </ResourceDictionary>
</Window.Resources>

Step 2: Apply the Custom Style

Apply the custom SfMaskedEdit style to the SfMaskedEdit control in your XAML.

XAML

<syncfusion:SfMaskedEdit Mask="-?\d+\.?\d*"
                MaskType="RegEx" Width="100" Height="25"
                Name="sfMaskedEdit" Style="{StaticResource CustomMaskedEditStyle}"/>

Output:

SfMaskedit.png

Conclusion

Hope you enjoyed learning about how to customize the SfMaskedEdit with rounded corner in WPF.

You can refer to our WPF SfMaskedEdit feature tour page to learn about its other groundbreaking feature representations. You can explore our WPF SfMaskedEdit documentation to understand how to present and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other components.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied