0

I searched a lot but I didn't find a solution for my problem.

I have an XML-File

<Module>
<Accounting>
    <tag tagname="tag1" displayname="display1">True</tag>
    <tag tagname="tag2" displayname="dispaly2">False</tag>
</Accounting>
</Module>

And that's my problem: I want to bind this XML-File to a listview where I can see the displayname and a checkbox where I am able to (un)check the tag (two-way-binding)

my XAML-file:

<ListView Height="134.113" Width="227.409" Margin="0,-100,30,10">
                    <ListViewItem>
                        <StackPanel>
                            <CheckBox IsChecked="{Binding XPath=./Module/Accounting/tag}">
                                <TextBlock Text="{Binding XPath=./Module/Accounting/tag/@displayname}"/>
                            </CheckBox>
                        </StackPanel>
                    </ListViewItem>
                </ListView>

But the listview only displays the first Item "display1" but not the second one.. anyone an idea why? (could there be any problem because I have (another) xmldataprovider?)

thanks
ps: sorry, english is not my first language ;)

4

1 に答える 1

2

アップデート:

私はあなたの問題が何であるかを理解しています... ItemsXAMLでアイテムを定義することによってコレクションを設定する場合(これはあなたがしていることです)...そしてあなたはItemsSource同様に設定することを許可されていません。

...を取り除いて、アイテムの表示方法を認識できるように、またはをListViewItem定義して、アイテムの表示方法を定義します。.View.ItemsTemplateListView

ここを参照してください:


次のように使用XmlDataProviderします。

XMLドキュメントに新しいノードを作成できるようにする場合は、次を使用します。

そして、ドキュメント内のアイテムにバインドします。

于 2012-07-31T13:09:40.320 に答える