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

时间:2013-08-21 08:47:26

标签: c# xaml silverlight-5.0

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

但是这给了我错误:

  

在样式

中找不到可附加属性触发器

1 个答案:

答案 0 :(得分:1)

您似乎没有指定Style应适用的属性telerikNavigation:RadTreeView.Style。截至目前,您获得Style作为Content

TreeView

尝试:

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