• 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>
  • 相关阅读:
    Pytest框架之命令行参数2
    Pytest框架之命令行参数1
    [编程题] 二维数组中的查找
    [编程题]二叉树镜像
    补充基础:栈与队列模型
    6641. 【GDOI20205.20模拟】Sequence
    瞎讲:任意模数MTT
    瞎讲:FFT三次变二次优化
    小米oj 重拍数组求最大和
    小米oj 有多少个公差为2的等差数列
  • 原文地址:https://www.cnblogs.com/chenyongblog/p/3570482.html
Copyright © 2020-2023  润新知