2

我有一个 RadTreeView并尝试使用 stye 触发器来禁用几个节点:

<telerikNavigation:RadTreeView  ItemTemplate="{StaticResource HierarchyItemsTreeItemTemplate}">
    <telerikNavigation:RadTreeView.Style>
            <Style TargetType="telerikNavigation:RadTreeView">
                <Style.Triggers>
                    <DataTrigger Binding="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=TreeViewItem}, Converter={StaticResource converter}}" Value="true">
                        <Setter Property="IsEnabled" Value="false"/>
                    </DataTrigger>
                </Style.Triggers>
            </Style>
        </telerikNavigation:RadTreeView.Style>
</telerikNavigation:RadTreeView >

但这给了我错误:

在 Style 中找不到可附加属性 Triggers

4

1 回答 1

3

您似乎没有指定您Style应该应用的属性是telerikNavigation:RadTreeView.Style. 到目前为止,你得到了一个Styleas Contentof theTreeView

尝试:

<telerikNavigation:RadTreeView ItemTemplate="{StaticResource HierarchyItemsTreeItemTemplate}">
  <telerikNavigation:RadTreeView.Style>  <!-- Missing Line from original Code -->
    <Style TargetType="telerikNavigation:RadTreeView">
      <Style.Triggers>
        <DataTrigger Binding="{Binding RelativeSource={RelativeSource FindAncestor,
                                                                      AncestorType=TreeViewItem},
                                        Converter={StaticResource converter}}"
                      Value="true">
          <Setter Property="IsEnabled"
                  Value="false" />
        </DataTrigger>
      </Style.Triggers>
    </Style>
  </telerikNavigation:RadTreeView.Style>  <!-- Missing Line from original Code -->
</telerikNavigation:RadTreeView>
于 2013-08-21T12:34:14.880 回答