0
我正在尝试在wpf c#中构建树视图。我需要我的父级和子级需要使用不同的颜色,我需要为该树视图中的所有父级完成此操作。如果任何节点包含任何颜色也需要更改的子节点。更改树视图中的子节点项目颜色wpf
我需要taht两栖在相同的背景色蜘蛛和所有子项应包含另一个背景颜色。这个怎么做......?
到目前为止,我已经尝试
<Window.Resources>
<Style TargetType="{x:Type TreeViewItem}">
<Setter Property="Background" Value="#4E4E4E"/>
<Setter Property="Foreground" Value="White"/>
<Setter Property="FontSize" Value="15"/>
</Style>
<Style x:Key="styTvMenu" TargetType="{x:Type TreeView}">
<Setter Property="Foreground" Value="Green"/>
</Style>
</Window.Resources>
<Grid>
<TreeView ItemsSource="{x:Static local:MainWindow.AnimalCategories}" Style="{StaticResource styTvMenu}" Margin="0,0,321,0">
<TreeView.ItemTemplate>
<HierarchicalDataTemplate ItemsSource="{Binding Path=Animals}">
<HierarchicalDataTemplate.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Path=Name}"/>
</DataTemplate>
</HierarchicalDataTemplate.ItemTemplate>
<TextBlock Text="{Binding Path=Category}" />
</HierarchicalDataTemplate>
</TreeView.ItemTemplate>
</TreeView>
</Grid>
由于它的工作原理 – Arshad
有没有什么方式来表明颜色整行..?现在它只填充文本。我需要它填充整行(treeview)宽度 – Arshad
@dahsra,http://stackoverflow.com/questions/15826637/wpf-treeview-item-background-over-entire-row和其相关问题 – ASh