zoukankan      html  css  js  c++  java
  • WPF-控件-层级控件-TreeView

    <?xml version="1.0" encoding="utf-8" ?>
    <Data xmlns="">
      <Grade Name="一年级">
        <Class Name="1班">
          <Group Name="A组"/>
          <Group Name="B组"/>
          <Group Name="C组"/>
          <Group Name="D组"/>
        </Class>
      </Grade>
      <Grade Name="二年级">
        <Class Name="1班">
          <Group Name="A组"/>
          <Group Name="B组"/>
          <Group Name="C组"/>
          <Group Name="D组"/>
        </Class>
      </Grade>
      <Grade Name="三年级">
        <Class Name="1班">
          <Group Name="A组"/>
          <Group Name="B组"/>
          <Group Name="C组"/>
          <Group Name="D组"/>
        </Class>
      </Grade>
    </Data>
    <Window x:Class="TreeView.MainWindow"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            Title="MainWindow" Height="350" Width="525">
        <Window.Resources>
            <!--数据源-->
            <XmlDataProvider x:Key="ds" Source="Data.xml" XPath="Data/Grade"/>
            <!--年级模板-->
            <HierarchicalDataTemplate DataType="Grade" ItemsSource="{Binding XPath=Class}">
                <TextBlock Text="{Binding XPath=@Name}"></TextBlock>
            </HierarchicalDataTemplate>
            <!--班级模板-->
            <HierarchicalDataTemplate DataType="Class" ItemsSource="{Binding XPath=Group}">
                <RadioButton Content="{Binding XPath=@Name}" GroupName="gn"></RadioButton>
            </HierarchicalDataTemplate>
            <!--小组模板-->
            <HierarchicalDataTemplate DataType="Group" ItemsSource="{Binding XPath=Student}">
                <CheckBox Content="{Binding XPath=@Name}"></CheckBox>
            </HierarchicalDataTemplate>
        </Window.Resources>
        <Grid>
            <TreeView ItemsSource="{Binding Source={StaticResource ds}}"></TreeView>
        </Grid>
    </Window>
  • 相关阅读:
    css侧边栏之综合实例3
    css侧边栏之综合实例2
    css实例之侧边栏
    css实例之正文
    css之使用 | margin | padding
    css之链接 | 点击后变色 | 悬停 | hover
    1.2(Mybatis学习笔记)Mybatis核心配置
    1.1(Mybatis学习笔记)初识Mybatis
    1.1(Spring学习笔记)Spring-事务基础
    1.4(Spring学习笔记)Spring-JDBC基础
  • 原文地址:https://www.cnblogs.com/chenyongblog/p/3570482.html
Copyright © 2011-2022 走看看