注册 登录
编程论坛 WPF/Silverlight

WPF数据模版问题

tianqy 发布于 2013-01-30 16:01, 641 次点击
XAML代码:
<Window x:Class="wpf6.MainWindow"
        xmlns="http://schemas.
        xmlns:x="http://schemas.
        Title="MainWindow" Height="300" Width="300">
    <Window.Resources>
        <!--数据源-->
        <XmlDataProvider x:Key="ds" Source="Data.xml" XPath="Data/Grade"/>
        <!--年级模版-->
        <HierarchicalDataTemplate DataType="Grade" ItemsSource="{Binding XPath=Grade}">
            <TextBlock Text="{Binding XPath=@Name}"/>
        </HierarchicalDataTemplate>
        <!--班级模版-->
        <HierarchicalDataTemplate DataType="Class" ItemsSource="{Binding XPath=Group}">
            <RadioButton Content="{Binding XPath=@Name}"  GroupName="gn" />
        </HierarchicalDataTemplate>
        <!--小组模版-->
        <HierarchicalDataTemplate DataType="Group" ItemsSource="{Binding XPath=Student}">
            <CheckBox Content="{Binding XPath=@Name}" />
        </HierarchicalDataTemplate>
    </Window.Resources>
    <Grid>
        <TreeView ItemsSource="{Binding Source={StaticResource ds}}" Margin="5"/>
    </Grid>
</Window>
Xml数据源:
<?xml version="1.0" encoding="utf-8" ?>
<Data xmlns="">
  <Grade Name="一年级">
    <Class Name="甲班">
      <Group Name="A组"/>
      <Group Name="B组"/>
      <Group Name="C组"/>
    </Class>
    <Class Name="乙班">
      <Group Name="A组"/>
      <Group Name="B组"/>
    </Class>
  </Grade>
  <Grade Name="二年级">
    <Class Name="甲班">
      <Group Name="A组"/>
      <Group Name="B组"/>
      <Group Name="C组"/>
    </Class>
    <Class Name="乙班">
      <Group Name="A组"/>
      <Group Name="B组"/>
    </Class>
  </Grade>
</Data>
截图为调试的,怎么年级展不开,班级、小组看不到,哪里的问题呢?求解,谢谢
1 回复
#2
abc657220912013-06-26 21:49
同求解~~~
1