我想去掉radtreeview的高光背景。我创建了一个样式来做这件事,但是我一直收到错误和异常,比如"Items集合必须为空“。如果我注释掉样式,应用程序运行良好,所以我知道这是问题的原因。我是WPF的新手,我确信我还不知道如何使用样式。谢谢你的帮助。下面是代码。
<Grid x:Name="LayoutRoot" Background="Salmon">
<telerik:RadTreeView x:Name="radTreeView" Margin="8" ItemsSource="{Binding Errors}" Background="Salmon" Style="{StaticResource treeStyle}">
<Style TargetType="{x:Type telerik:RadTreeViewItem}" x:Name="treeStyle">
<Setter Property="Focusable" Value="False"/>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter Property="Background" Value="{x:Null}"/>
<Setter Property="BorderBrush" Value="{x:Null}"/>
</Trigger>
</Style.Triggers>
</Style>
<telerik:RadTreeView.ItemTemplate>
<HierarchicalDataTemplate ItemsSource="{Binding SubItems}" >
<Grid Background="Salmon">
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<TextBlock Text="{Binding Description}" IsHitTestVisible="False" />
<ListBox Grid.Row="1" ItemsSource="{Binding Messages}" Margin="20,0,0,0" BorderBrush="#00000000" BorderThickness="0" Background="Salmon" IsHitTestVisible="False" >
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Message}"/>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
</HierarchicalDataTemplate>
</telerik:RadTreeView.ItemTemplate>
</telerik:RadTreeView>
</Grid>
</UserControl>如果你知道这是行不通的,我也试着用样式代码去掉高亮部分:
<Style TargetType="TreeViewItem">
<Style.Resources>
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="#FFF"/>
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightTextBrushKey}" Color="#000"/>
</Style.Resources>
</Style>发布于 2012-05-31 00:47:52
您会得到异常,因为您的样式标记实际上是树中的一个项目,并且您设置了ItemsSource。
用<telerik:RadTreeView.ItemContainerStyle>标记将样式括起来。
这应该可以解决异常,但它不会给出您所期望的结果,因为树视图项的控件模板实际上显示了另一个不受Background属性影响的边框。您将需要更改控件模板。
Telerik会在不同版本之间改变样式,所以给你一个错误版本的模板可能对你没有帮助。
但是,您可以转到Telerik的安装文件夹并查找名为"Themes“的文件夹。在那里,您将找到一个包含telerik所有主题的解决方案。
x:Name="MouseOver"的VisualState并删除其中的序列图像板。https://stackoverflow.com/questions/10817892
复制相似问题