代码改变世界

wpf TreeView

2014-08-05 16:32  愿得一人心  阅读(185)  评论(0编辑  收藏  举报
<Window x:Class="Mysql.DepartmentParson"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:s="clr-namespace:System.Collections.Generic;assembly=mscorlib"
        xmlns:local="clr-namespace:Mysql.ServiceReference1"
        Title="DepartmentParson" Height="300" Width="300">
    <Grid>
        <TreeView Name="Tree" HorizontalAlignment="Left"  Height="269"  Width="292" >
            <TreeView.ItemTemplate>
                <HierarchicalDataTemplate ItemsSource="{Binding Value}">
                    <StackPanel>
                        <TextBlock  Text="{Binding Key.DepartmentName}" Background="Red" />
                    </StackPanel>
                    <HierarchicalDataTemplate.ItemTemplate>
                        <HierarchicalDataTemplate>
                            <TextBlock Text="{Binding Path=ParsonName}"/>
                        </HierarchicalDataTemplate>
                    </HierarchicalDataTemplate.ItemTemplate>
                </HierarchicalDataTemplate>
            </TreeView.ItemTemplate>
        </TreeView>
    </Grid>
</Window>