0
我在下面有一些簡單的XAML,我的問題是,爲什麼不在列表框中顯示文本?我得到的是兩條可選擇的線路!僅在XAML中綁定XML屬性
<Window x:Class="DataTemplateEditor.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">
<Grid>
<Grid.DataContext>
<XmlDataProvider Source="datatemplate.xml" XPath="Tables/Table" />
</Grid.DataContext>
<DockPanel HorizontalAlignment="Stretch" Name="dockPanel1" VerticalAlignment="Stretch">
<ListBox Name="listBox1" Width="150" DockPanel.Dock="Left" ItemsSource="{Binding}" IsSynchronizedWithCurrentItem="True">
<ListBox.Resources>
<DataTemplate x:Key="MyDataTemplate">
<StackPanel Orientation="Vertical">
<TextBlock Text="{Binding [email protected]}" />
</StackPanel>
</DataTemplate>
</ListBox.Resources>
</ListBox>
<ListView Name="listBox2" DockPanel.Dock="Right" />
</DockPanel>
</Grid>
<?xml version="1.0" encoding="utf-8" ?>
<Tables>
<Table Name="People">
<Field Name="id" Type="Number" PrimaryKey="true" Indexed="true" AllowNull="false"/>
<Field Name="FirstName" Type="Number" PrimaryKey="true" Indexed="true" AllowNull="false"/>
</Table>
<Table Name="Purchases">
<Field Name="id" Type="Number" PrimaryKey="true" Indexed="true" AllowNull="false"/>
</Table>
</Tables>