• 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>
  • 相关阅读:
    UWP 视觉状态管理 VisualStateManager
    RainbowEight
    Thread.Sleep在WinRT中---uwp应用
    fsasefa
    那年坑系列之好多坑_by二卷
    deep Learning Introduction_1_by二卷
    笔记本无线联网时VirtualBox的联网问题_by二卷
    Linux入门篇之目录结构_by二卷_待补充
    Python核心编程Ⅱ章3Python基础_by二卷
    数据挖掘导论章3探索数据_by二卷
  • 原文地址:https://www.cnblogs.com/chenyongblog/p/3570482.html
Copyright © 2020-2023  润新知