Гость
Форумы / WPF, Silverlight [игнор отключен] [закрыт для гостей] / Проблема со зверем "HierarchicalDataTemplate" / 1 сообщений из 1, страница 1 из 1
06.11.2012, 10:01
    #38026274
DDorgNev
Гость
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Проблема со зверем "HierarchicalDataTemplate"
Здравствуйте.
Есть файл XML:

Код: xml
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
<?xml version="1.0" encoding="utf-8" ?>
<Structure>
  <Classes>
    <Class ID="C0" Caption="AAA"/>
    <Class ID="C1" Caption="BBB"/>
    <Class ID="C2" Caption="CCC"/>
    <Class ID="C3" Caption="DDD"/>
  </Classes>
  <Objects>
    <Object ID="" Caption="A">
      <Property ID="" Caption="subA" />
      <Property ID="" Caption="subB" />
      <Property ID="" Caption="subC" />
      <Property ID="" Caption="subD" />
    </Object>
    <Object ID="" Caption="B" >
      <Property ID="" Caption="suba" />
      <Property ID="" Caption="subb" />
      <Property ID="" Caption="subc" />
    </Object>
    <Object ID="" Caption="C" >
      <Object ID="" Caption="aA" />
      <Object ID="" Caption="bB" />
      <Object ID="" Caption="cC" />
      <Object ID="" Caption="dD" />
    </Object>
  </Objects>
  <Events>
    <Event ID="" Caption="" />
  </Events>
</Structure>



Есть такая попытка показать содержимое файла:

Код: xml
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
<HierarchicalDataTemplate DataType="Classes" ItemsSource="{Binding XPath=Class}">
  <StackPanel Orientation="Horizontal">
    ...
  </StackPanel>
</HierarchicalDataTemplate>

<HierarchicalDataTemplate DataType="Class" >
  <StackPanel Orientation="Horizontal">
    ...
  </StackPanel>
</HierarchicalDataTemplate>

<HierarchicalDataTemplate DataType="Objects" ItemsSource="{Binding XPath=Object}">
  <StackPanel Orientation="Horizontal">
    ...
  </StackPanel>
</HierarchicalDataTemplate>

<HierarchicalDataTemplate DataType="Object" ItemsSource="{Binding XPath=./*}" >
  <StackPanel Orientation="Horizontal">
    ...
  </StackPanel>
</HierarchicalDataTemplate>

<HierarchicalDataTemplate DataType="Property" >
  <StackPanel Orientation="Horizontal">
    ...
  </StackPanel>
</HierarchicalDataTemplate>


<HierarchicalDataTemplate DataType="Events" ItemsSource="{Binding XPath=Event}">
  <StackPanel Orientation="Horizontal">
    ...
  </StackPanel>
</HierarchicalDataTemplate>

<HierarchicalDataTemplate DataType="Event" >
  <StackPanel Orientation="Horizontal">
    ...
  </StackPanel>
</HierarchicalDataTemplate>



в таком TreeView:

Код: xml
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
        <Grid.DataContext>
            <XmlDataProvider x:Name="StructureData" Source="Structure.xml" XPath="Structure" />
        </Grid.DataContext>
        <TreeView 
          x:Name="trvEntities" 
          Grid.Column="0" 
          HorizontalAlignment="Stretch" 
          VerticalAlignment="Stretch" 
          Margin="3,3,8,3" 
          ItemsSource="{Binding}"
          VirtualizingStackPanel.IsVirtualizing="False" 
          VirtualizingStackPanel.VirtualizationMode="Standard" />



Всего-то хотел отобразить каждый тип узла с разным набором контролов.
Но в TreeView - пусто.
Подскажите, пожалуйста, где я ошибаюсь, и как это поправить?
...
Рейтинг: 0 / 0
Форумы / WPF, Silverlight [игнор отключен] [закрыт для гостей] / Проблема со зверем "HierarchicalDataTemplate" / 1 сообщений из 1, страница 1 из 1
Целевая тема:
Создать новую тему:
Автор:
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]