I'm using the Telerik UI for WPF framework. This includes the RadMaskedTextInput
control and I struggle to set the ClearButtonStyle
. How can I assign a style to it in code-behind?
Assign a name to your RadMaskedTextInput
control in XAML.
<telerik:RadMaskedTextInput x:Name="MaskedTextInput"/>
If your style is defined with a in XAML, use FindResouce
<Style x:Key="MaskedTextInputStyle" TargetType="{x:Type telerik:RadButton}">
<!-- Your style definitions -->
</Style>
var clearButtonStyle = (Style) FindResource("YourResourceKey");
You can also create the style in code-behind. Add e.g. setters and triggers to the corresponding collections.
var clearButtonStyle = new Style(typeof(RadButton));
Then in code-behind - the *.xaml.cs
file - assign the style.
MaskedTextInput.ClearButtonStyle = clearButtonStyle;