Articles in this section
Category / Section

How to disable tooltip based on Validation failure in SfMaskedEdit?

1 min read

To disable tool-tip “invalid” in SfMaskedEdit, customize the template of SfMaskedEdit control. This can be achieved by removing the style of Error_Popup from SfMaskedEdit template. The same has been explained in the following code.

 

 
<Page.Resources>
        <SolidColorBrush x:Key="SyncfusionTextBoxExtErrorThemeBrush" Color="Red" />
        <Style x:Key="MaskEditStyle" TargetType="Input:SfMaskedEdit">
            <Setter Property="MinWidth" Value="{StaticResource 
                                  TextControlThemeMinWidth}"/>
            <Setter Property="TextAlignment" Value="Left"/>
            <Setter Property="MinHeight" Value="{StaticResource 
                                  TextControlThemeMinHeight}"/>
            <Setter Property="Foreground" Value="{StaticResource 
                                TextBoxForegroundThemeBrush}"/>
            <Setter Property="Background" Value="{StaticResource 
                              TextBoxBackgroundThemeBrush}"/>
            <Setter Property="BorderBrush" Value="{StaticResource 
                                 TextBoxBorderThemeBrush}"/>
            <Setter Property="BorderThickness" Value="{StaticResource 
                               TextControlBorderThemeThickness}"/>
            <Setter Property="FontFamily" Value="{StaticResource 
                              ContentControlThemeFontFamily}"/>
            <Setter Property="FontSize" Value="20"/>
            <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" 
                           Value="Hidden"/>
            <Setter Property="ScrollViewer.VerticalScrollBarVisibility" 
                        Value="Hidden"/>
            <Setter Property="ScrollViewer.IsDeferredScrollingEnabled" Value="False"/>
            <Setter Property="Padding" Value="{StaticResource 
                                 TextControlThemePadding}"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="Input:SfMaskedEdit">
                        <Grid>
                            <VisualStateManager.VisualStateGroups>
                                <VisualStateGroup x:Name="CommonStates">
                                    <VisualState x:Name="Disabled">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Storyboard.TargetName="BackgroundElement">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource TextBoxDisabledBackgroundThemeBrush}"/>
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="BorderBrush" Storyboard.TargetName="BorderElement">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource TextBoxDisabledBorderThemeBrush}"/>
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="ContentElement">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource TextBoxDisabledForegroundThemeBrush}"/>
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="Normal">
                                        <Storyboard>
                                            <DoubleAnimation Duration="0" To="{StaticResource TextControlBackgroundThemeOpacity}" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="BackgroundElement"/>
                                            <DoubleAnimation Duration="0" To="{StaticResource TextControlBorderThemeOpacity}" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="BorderElement"/>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="PointerOver">
                                        <Storyboard>
                                            <DoubleAnimation Duration="0" To="{StaticResource TextControlPointerOverBackgroundThemeOpacity}" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="BackgroundElement"/>
                                            <DoubleAnimation Duration="0" To="{StaticResource TextControlPointerOverBorderThemeOpacity}" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="BorderElement"/>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="Focused">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="BorderBrush" Storyboard.TargetName="BorderElement">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource TextSelectionHighlightColorThemeBrush}"/>
                                            </ObjectAnimationUsingKeyFrames>
                                            <DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="PlaceholderTextContentPresenter"/>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Storyboard.TargetName="BackgroundElement">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource TextBoxFocusedBackgroundThemeBrush}"/>
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                </VisualStateGroup>
                                <VisualStateGroup x:Name="PopupStates">
                                    <VisualState x:Name="TopLight">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="BorderThickness" Storyboard.TargetName="PART_SuggestionBox">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="2 2 2 0"/>
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="BottomLight">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="BorderThickness" Storyboard.TargetName="PART_SuggestionBox">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="2 0 2 2"/>
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="TopDark">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="BorderThickness" Storyboard.TargetName="PART_SuggestionBox">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="2"/>
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="BottomDark">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="BorderThickness" Storyboard.TargetName="PART_SuggestionBox">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="2"/>
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                </VisualStateGroup>
                                <VisualStateGroup x:Name="ErrorStates">
                                    <VisualState x:Name="HasError">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="BorderBrush" Storyboard.TargetName="BorderElement">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource SyncfusionTextBoxExtErrorThemeBrush}"/>
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="NoError"/>
                                </VisualStateGroup>
                            </VisualStateManager.VisualStateGroups>
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="*"/>
                                    <ColumnDefinition Width="Auto"/>
                                </Grid.ColumnDefinitions>
                                <Border x:Name="BackgroundElement" 
                                Background="{TemplateBinding Background}" 
                                Grid.ColumnSpan="2" Margin="{TemplateBinding 
                                BorderThickness}"/>
                                <Border x:Name="BorderElement" 
                                BorderBrush="{TemplateBinding BorderBrush}" 
                                BorderThickness="{TemplateBinding BorderThickness}" 
                                Grid.ColumnSpan="2"/>
                                <ContentControl x:Name="PART_Watermark" 
                                  IsTabStop="False" Content="{Binding 
                                  Watermark,RelativeSource={RelativeSource 
                                  Mode=TemplatedParent}}" ContentTemplate="{Binding  
                                  WatermarkTemplate,RelativeSource={RelativeSource 
                                  Mode=TemplatedParent}}"   
                                  ContentTemplateSelector="{Binding 
                               WatermarkTemplateSelector,RelativeSource={RelativeSource
                               Mode=TemplatedParent}}" Margin="{TemplateBinding 
                               BorderThickness}" Padding="{TemplateBinding Padding}"/>
                                <ScrollViewer x:Name="ContentElement" 
                                  HorizontalScrollMode="{TemplateBinding 
                                ScrollViewer.HorizontalScrollMode}" 
                                  HorizontalScrollBarVisibility="{TemplateBinding 
                                  ScrollViewer.HorizontalScrollBarVisibility}"
                                  IsTabStop="False" 
                                  IsHorizontalRailEnabled="{TemplateBinding 
                                  ScrollViewer.IsHorizontalRailEnabled}" 
                                  IsVerticalRailEnabled="{TemplateBinding 
                                  ScrollViewer.IsVerticalRailEnabled}" 
                                  IsDeferredScrollingEnabled="{TemplateBinding 
                                  ScrollViewer.IsDeferredScrollingEnabled}" 
                                  Margin="{TemplateBinding BorderThickness}" 
                                  Padding="{TemplateBinding Padding}" 
                                  VerticalScrollBarVisibility="{TemplateBinding 
                                  ScrollViewer.VerticalScrollBarVisibility}" 
                                  VerticalScrollMode="{TemplateBinding 
                                  ScrollViewer.VerticalScrollMode}" 
                                  ZoomMode="Disabled"/>
                                <ContentControl 
                                 x:Name="PlaceholderTextContentPresenter" 
                                 Content="{TemplateBinding PlaceholderText}" 
                                  Foreground="{ThemeResource 
                                 TextBoxPlaceholderTextThemeBrush}" 
                                 FontSize="{ThemeResource ContentControlFontSize}" 
                                 IsTabStop="False" Margin="{TemplateBinding 
                                 BorderThickness}" Padding="{TemplateBinding Padding}"
                                    Grid.Row="1"/>
                            </Grid>
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </Page.Resources>
    <Grid>
        <Input:SfMaskedEdit x:Name="maskededit" HorizontalAlignment="Center" 
                  MaskType="Simple" Mask="00-0000-0000"  TextWrapping="Wrap"  
                  VerticalAlignment="Center" Width="255" Height="46" 
                  Style="{StaticResource MaskEditStyle}"/>
    </Grid>

 

 

 

 

 

 

 

 

 

 

Output:

 

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