<Window x:Class="WpfApp1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WpfApp1"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Grid>
<TreeView Name="trvMenu">
<TreeView.Resources>
<HierarchicalDataTemplate DataType="{x:Type local:Class}" ItemsSource="{Binding Students}">
<StackPanel Orientation="Horizontal">
<Image Source="D:\代码\WpfApp18 - 副本 - 副本\WpfApp1\1.jpg" Width="30" Height="30"/>
<TextBlock Text="{Binding ClassName}" />
<TextBlock Text=" [" Foreground="Blue" />
<TextBlock Text="{Binding Teacher}" Foreground="Blue" />
<TextBlock Text="]" Foreground="Blue" />
</StackPanel>
</HierarchicalDataTemplate>
<DataTemplate DataType="{x:Type local:Student}">
<StackPanel Orientation="Horizontal">
<Image Source="D:\代码\WpfApp18 - 副本 - 副本\WpfApp1\1.jpg" Width="30&#
C# WPF TreeView 等级显示条目
最新推荐文章于 2024-04-01 19:17:30 发布