WPF的Telerik UI-如何在代码后面设置RadMaskedTextInput的ClearButtonStyle



我正在使用WPF框架的Telerik UI。这包括RadMaskedTextInput控制和我努力设置ClearButtonStyle。如何在代码隐藏中为其指定样式?

在XAML中为RadMaskedTextInput控件指定一个名称。

<telerik:RadMaskedTextInput x:Name="MaskedTextInput"/>

如果您的样式是用XAML中的定义的,请使用FindResouce

<Style x:Key="MaskedTextInputStyle" TargetType="{x:Type telerik:RadButton}">
<!-- Your style definitions -->
</Style>
var clearButtonStyle = (Style) FindResource("YourResourceKey");

您也可以在代码隐藏中创建样式。将例如setter和触发器添加到相应的集合中。

var clearButtonStyle = new Style(typeof(RadButton));

然后在代码后面的*.xaml.cs文件中指定样式。

MaskedTextInput.ClearButtonStyle = clearButtonStyle;

最新更新