Silverlight 通过样式绑定在RadTreeViewItem上启用设置

Silverlight 通过样式绑定在RadTreeViewItem上启用设置,silverlight,telerik,radtreeview,Silverlight,Telerik,Radtreeview,我正在将一个分层集合绑定到一个RadTreeView,效果很好。现在,我想基于名为PermissionID的布尔属性的值禁用项 当我尝试此操作时,我的模块(这是一个PRISM应用程序)的InitializeComponent失败,出现异常: {System.Windows.Markup.XamlParseException: Set property '' threw an exception. [Line: 19 Position: 48] ---> System.NotSupporte

我正在将一个分层集合绑定到一个RadTreeView,效果很好。现在,我想基于名为PermissionID的布尔属性的值禁用项

当我尝试此操作时,我的模块(这是一个PRISM应用程序)的
InitializeComponent
失败,出现异常:

{System.Windows.Markup.XamlParseException: Set property '' threw an exception. [Line: 19 Position: 48] ---> System.NotSupportedException: Cannot set read-only property ''.
   at MS.Internal.XamlMemberInfo.SetValue(Object target, Object value)
   at MS.Internal.XamlManagedRuntimeRPInvokes.SetValue(XamlTypeToken inType, XamlQualifiedObject& inObj, XamlPropertyToken inProperty, XamlQualifiedObject& inValue)
   --- End of inner exception stack trace ---
   at System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)
   at InventoryModule.Views.NavigationView.InventoryNavigation.InitializeComponent()
   at InventoryModule.Views.NavigationView.InventoryNavigation..ctor()}
它看起来好像在说IsEnabled属性是只读的,但它不是

这是我的XAML:

<UserControl.Resources>
        <telerik:HierarchicalDataTemplate x:Key="ItemTemplate" ItemsSource="{Binding vw_Module_Access_Permissions_1}">
            <TextBlock Text="{Binding Module_Function_Caption}" />
        </telerik:HierarchicalDataTemplate>
        <Style x:Key="ItemContainerStyle" TargetType="telerikNavigation:RadTreeViewItem">
            <Setter Property="IsExpanded" Value="True"/>
            <Setter Property="IsEnabled" Value="{Binding Path=PermissionID}" />
        </Style>
    </UserControl.Resources>

    <Grid x:Name="LayoutRoot" Background="White">
        <telerikNavigation:RadTreeView x:Name="InventoryNavigationTree" ItemContainerStyle="{StaticResource ItemContainerStyle}" ItemsSource="{Binding SecuredModuleFunctions}"
                                       ItemTemplate="{StaticResource ItemTemplate}">
            <i:Interaction.Triggers>
                <i:EventTrigger EventName="MouseLeftButtonUp">
                    <inf:InvokeDelegateCommandAction Command="{Binding OpenView}" CommandParameter="{Binding ElementName=InventoryNavigationTree, Path=SelectedItem}"></inf:InvokeDelegateCommandAction>
                </i:EventTrigger>
            </i:Interaction.Triggers>
        </telerikNavigation:RadTreeView>

    </Grid>

这是Silverlight吗

Silverlight中还没有样式绑定(在Silverlight 5.0中推出)

Telerik具有“容器绑定”,其作用方式类似,但设置在DataTemplate上,而不是样式上:

从他们的文档中:

<telerik:ContainerBindingCollection x:Name="BindingsCollection">  
    <telerik:ContainerBinding PropertyName="IsSelected" Binding="{Binding Selected, Mode=TwoWay}" />  
    <telerik:ContainerBinding PropertyName="IsExpanded" Binding="{Binding Expanded, Mode=TwoWay}" />  
</telerik:ContainerBindingCollection>  

希望这在你的情况下能起作用

这起作用了!我必须在HierarchycalDataTemplate上设置BindingCollections,它完全按照我的需要禁用这些项。谢谢
telerik:ContainerBinding.ContainerBindings="{StaticResource BindingsCollection}"