当radtreeview内的itemptionlistType =“清单”时,有没有办法更改复选框的样式?

有帮助吗?

解决方案

我能想到有几种方法可以做到这一点,但遗憾的是它们都不是特别容易。

一种方法是使用 Blend 或类似工具来获取 RadTreeViewItem 类的模板。RadTreeViewItem 类及其模板位于 Telerik.Windows.Controls.Navigation 程序集中。复制此模板并修改 CheckBox 在此模板中可以根据需要自定义其外观。

要使用该模板,请添加 ControlTemplate 和一个 Style<UserControl.Resources> XAML 页面的元素,如下所示:

<UserControl.Resources>
    <ControlTemplate x:Key="myRadTreeViewItemTemplate" TargetType="telerik:RadTreeViewItem">
        <!-- modified template goes here... -->
    </ControlTemplate>
    <Style TargetType="telerik:RadTreeViewItem">
        <Setter Property="Template" Value={StaticResource myRadTreeViewItemTemplate}" />
    </Style>
</UserControl.Resources>

然后,这应该将修改后的模板应用到同一 XAML 文件中的任何 RadTreeView。

请注意,我们必须使用 隐式风格 (IE。一个没有 x:Key),因为似乎没有其他方法可以告诉 RadTreeView 将给定样式应用于其子项。


或者,您可以 修改内置主题. 。此方法还可以更改应用程序中其他 Telerik 控件中使用的复选框的样式,例如 RadGridView 中的 GridViewCheckBoxColumn 中。


编辑:如果默认情况下需要在Radtreeview中使用的复选框模板,则在Telerik.windows.controls Assembly中的主题 Office Office Office Office Office Office Office Office Office Office Black System.Controls.xaml中找到它。这假设您使用的是“Office Black”主题;如果您使用不同的 Telerik 主题,请调整此文件的路径。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top