我有一個XML文件,它看起來像:WPF的DataGrid綁定到一個XML文件顯示了意外的行爲
tech.xml
<?xml version="1.0" encoding="utf-8" ?>
<Tech>
<item ID="1" CATEGORY="example_1" NAME="example1" MIN_LEVEL1 ="1" MAX_LEVEL1 ="10"/>
.
.
<item ID="102" CATEGORY="example_1222" NAME="example1333" MIN_LEVEL1 ="1" MAX_LEVEL1 ="10"/>
</Tech>
我使用的是xmldataprovider
結合這一個DataGrid的DataGridTextColumn<XmlDataProvider x:Key="tech" Source="tech.xml" XPath="Tech" />
這樣
<DataGrid ItemsSource="{Binding someotherclass}">
<DataGridTextColumn Binding Source="{StaticResource tech}" XPath="@NAME" />
.
.
.
other datagrid columns...
</DataGrid>
我遇到的問題是,DataGridTextColumn輸出中的所有行都顯示值「example1」
而不是像所期望的值example1 .... example1333。
請注意,datagrid ItemsSource綁定到某個其他數據文件,只有DataGridTextColumn綁定到tech.xml。
你知道'DataGrid'將遍歷基於其'ItemsSource'財產的所有行? – stukselbax 2012-04-25 05:28:18