Hi,
How can I completely remove or hide Context Menu (aka Copy/Past menu) appearing when I'm right-clicking on the `telerik:RadMaskedTextInput`?
4 Answers, 1 is accepted
Hello Arsen,
The context menu that appears when you right click on the masked input control is the default one that comes with the native TextBox element. In order to prevent it from displaying you can use the TextBoxStyle property of the masked input controls. Here is an example:
<telerik:RadMaskedTextInput>
<telerik:RadMaskedTextInput.TextBoxStyle>
<Style TargetType="TextBox">
<Setter Property="ContextMenuService.ContextMenu">
<Setter.Value>
<ContextMenu Width="0" Height="0" />
</Setter.Value>
</Setter>
<Setter Property="BorderThickness" Value="0" />
</Style>
</telerik:RadRadMaskedCurrencyInput.TextBoxStyle>
</telerik:RadMaskedCurrencyInput>
Can you try this and let me know how it goes?
Regards,
Martin Ivanov
Progress Telerik
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.
This works, thank you!
However, it is also overriding the default styles (textbox) of the application and particularly for my case it's making the mouse left click not working.
I was able to fix the problem by putting :
BasedOn="{StaticResource {x:Type TextBox}}"
However this doesn't fix the problem completely, particularly our styles for RadMaskedInput are based on RadMaskedInputBaseStyle
and now when focusing on the textbox I can see a white background.
Is there any other workaround instead of putting Height and Width to 0?
To be honest for me, this is not the best option.
I was able to fix the problem by pointing to PreviewInputTextbox type instead of TextBox:
<
telerik:RadMaskedTextInput.TextBoxStyle
>
<
Style
TargetType
=
"{x:Type maskedInput:PreviewInputTextBox}"
BasedOn
=
"{StaticResource MaskedInputTextBoxStyle}"
>
<
Setter
Property
=
"ContextMenuService.ContextMenu"
>
<
Setter.Value
>
<
ContextMenu
Visibility
=
"Collapsed"
/>
</
Setter.Value
>
</
Setter
>
</
Style
>
</
telerik:RadMaskedTextInput.TextBoxStyle
>
Please note that using Visibility="Collapsed" is a better alternative of putting element Height and Width to 0 because in the last case, the element still exists in the UI, but just with no dimensions, which is itself error-prone.
Hello Arsen,
Thank you for sharing your solution. Indeed, PreviewInputTextbox is the more appropriate TargetType for the style.
Regards,
Martin Ivanov
Progress Telerik
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.