This is a migrated thread and some comments may be shown as answers.

The attachable property Triggers was not found in Style wile writing Style Triggers

1 Answer 625 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Subhendu
Top achievements
Rank 1
Subhendu asked on 21 Aug 2013, 09:17 AM
I have a  RadTreeView and I am trying to use stye triggers for disabling few nodes:
<telerikNavigation:RadTreeView  ItemTemplate="{StaticResource HierarchyItemsTreeItemTemplate}">
        <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 >

But this gives me error: The attachable property Triggers was not found in Style.  Is there any alternate approach and Triggers are being obsolete?

1 Answer, 1 is accepted

Sort by
0
Tina Stancheva
Telerik team
answered on 21 Aug 2013, 07:21 PM
Hello,

Unfortunately I can't tell for sure what's going wrong with your approach as I can't reproduce this issue locally. However, I feel that there might be something missing in the code snippet you sent as you can't place a style definition directly within a RadTreeView definition.

Another thing I've noticed is that your DataTrigger is looking for an object of type TreeViewItem but you're working with RadTreeView and I'm not sure whether you've placed the RadTreeView within a native TreeView control or if this is a typo.

In any case, if your scenario requires an implementation where the RadTreeViewItems are disabled based on the value of a property from their underlying business object then you can use one of two approaches:
  • use DataTriggers but in the Triggers section of a Style targeting telerik:RadTreeViewItem:
<Style TargetType="telerik:RadTreeViewItem">
    <Style.Triggers>
        <DataTrigger Binding="{Binding Unavailable}" Value="true">
            <Setter Property="IsEnabled" Value="false" />
        </DataTrigger>
    </Style.Triggers>
</Style>

  • use a Style Setter and bind the RadTreeViewItem IsEnabled property to a business property
<Style TargetType="telerik:RadTreeViewItem">
    <Setter Property="IsEnabled" Value="{Binding Unavailable}" />
</Style>

I demonstrated both approaches in the attached sample so please let me know if they help.

Regards,
Tina Stancheva
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
TreeView
Asked by
Subhendu
Top achievements
Rank 1
Answers by
Tina Stancheva
Telerik team
Share this question
or