سؤال

Is there a way to change the style of checkboxes when the ItemsOptionListType="CheckList" inside a RadTreeView?

هل كانت مفيدة؟

المحلول

There are a couple of ways of doing this that I can think of, but sadly neither of them is particularly easy.

One way is to use Blend or a similar tool to obtain the template for the RadTreeViewItem class. The RadTreeViewItem class and its template are in the Telerik.Windows.Controls.Navigation assembly. Take a copy of this template and modify the CheckBox within this template to customise its appearance as you wish.

To use the template, add a ControlTemplate and a Style to the <UserControl.Resources> element of a XAML page, as follows:

<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>

This should then apply the modified template to any RadTreeViews in the same XAML file.

Note that we have to use an implicit style (i.e. one without an x:Key), since there seems to be no other way to tell a RadTreeView to apply a given style to its child items.


Alternatively, you can modify a built-in theme. This approach could also change the styles of CheckBoxes used within other Telerik controls in your application, for example in a GridViewCheckBoxColumn within a RadGridView.


EDIT: if you want the template for the CheckBox as used in the RadTreeView by default, you'll find it in Themes\Office\Black\System.Windows.Controls.xaml within the Telerik.Windows.Controls assembly. This assumes you're using the 'Office Black' theme; adjust the path of this file if you're using a different Telerik theme.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top