C#Hierarchical TreeView显示额外级别

时间:2018-04-05 14:07:50

标签: c# treeview hierarchical

我该怎么做......

Field
--Crop year <-- property of crop. I want here an extra level for sorting like 2017 or 2018
---Crop
----Fertilizer
----Pesticide

... if&#34; Crop year&#34;是作物的日期时间。我怎样才能获得额外的水平&#34;年&#34;?

    <TreeView x:Name="tvFields" Margin="10" HorizontalContentAlignment="Stretch">
        <TreeView.Resources>
            <HierarchicalDataTemplate DataType="{x:Type entites:Field}" ItemsSource="{Binding Items}">
                <StackPanel Orientation="Horizontal" Background="LightGreen">
                    <TextBlock Text="{Binding Name}" FontSize="16"/>
                </StackPanel>
            </HierarchicalDataTemplate>
            <HierarchicalDataTemplate DataType="{x:Type entites:Crop}" ItemsSource="{Binding PestItems}">
                <StackPanel Orientation="Horizontal" Background="LightBlue">
                    <TextBlock Text="{Binding Name}" FontSize="14" />
                </StackPanel>
            </HierarchicalDataTemplate>
            <HierarchicalDataTemplate DataType="{x:Type entites:Pesticide}" ItemsSource="{Binding PestItems}">
                <StackPanel Orientation="Horizontal" Background="PaleGreen">
                    <TextBlock Text="{Binding Name}" FontSize="14" />
                </StackPanel>
            </HierarchicalDataTemplate>
            <HierarchicalDataTemplate DataType="{x:Type entites:Fertilizer}" ItemsSource="{Binding FertItems}">
                <StackPanel Orientation="Horizontal" Background="Beige">
                    <TextBlock Text="{Binding Name}" FontSize="14" />
                </StackPanel>
            </HierarchicalDataTemplate>
        </TreeView.Resources>
    </TreeView>

我应该为&#34; Crop year&#34;?

创建一个额外的课程

Lyror

0 个答案:

没有答案