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>