1

该应用程序基于使用 Prism 和 MEF 的 MVVM。我已将 Windows 树视图控件转换为 Telerik RadTreeview 控件。一切正常,除了定义的 ItemContainerStyle 以某种方式禁用要显示的树。如果我从 Radtreeview 中删除 ItemContainerStyle,则树变得可见但没有样式。通过使用具有相同 ItemcontainerStyle 的 windows 树视图可以正常工作。以下是代码。

    <uxc:UxtWindow.Resources> 
 <HierarchicalDataTemplate x:Key="SiteWizardTemplate" ItemsSource="{Binding Steps}" > 
            <StackPanel Orientation="Horizontal"> 
                <TextBlock Text="{Binding DisplayAs}" /> 
            </StackPanel> 
        </HierarchicalDataTemplate> 
    </uxc:UxtWindow.Resources> 

 <telerik:RadTreeView IsVirtualizing="True" ItemsSource="{Binding Wizard.WizardSections}" 
                          ItemTemplate="{StaticResource SiteWizardTemplate}"                                          
                               PreviewMouseDown="TreeView_PreviewMouseDown" > 
                               <telerik:RadTreeView.ItemContainerStyle> 
                                <Style TargetType="{x:Type telerik:RadTreeViewItem}"> 
                                    <Setter Property="FontSize" Value="18" /> 
                                    <Setter Property="FontStyle" Value="Italic" /> 
                                    <Setter Property="Margin" Value="0,5,0,10" /> 
                                    <Setter Property="Foreground" Value="Black" /> 
                    </telerik:RadTreeView.ItemContainerStyle>   

</telerik:RadTreeView> 
4

1 回答 1

1

我认为您必须使用BasedOnProperty 扩展现有样式,而不仅仅是覆盖它:

<Style TargetType="{x:Type telerik:RadTreeViewItem}" BasedOn="{StaticResource {x:Type telerik:RadTreeViewItem}}">

哦,删除你的ItemTemplate: 你不能同时设置ItemTemplateItemContainerStyle

于 2013-07-11T16:09:47.210 回答