是否有一種方法(使用MVVM模式)將ListView動態綁定到xml文件? 其實ListView控件被綁定到一個靜態的路徑,如:WPF - 動態綁定ListView到.xml文件
C:\DocumentsAndSettings\blabla\morebla\log.xml
我需要這樣的東西
AppPath\log.xml
這裏是我的代碼: 在View.xaml:
<ListView ItemsSource="{Binding Source={StaticResource logDataSource}, ...
在App.xaml:
<XmlDataProvider x:Key="logDataSource"
Source="C:\DocumentsAndSettings\blabla\morebla\log.xml"
d:IsDataSource="True"/>
我想是這樣的:
<XmlDataProvider x:Key="logDataSource"
Source="AppPath\log.xml"
d:IsDataSource="True"/>
預先感謝您。
在你的情況看起來你已經把'log.xml'放在了項目的根目錄下。所以試試' ' –
mg007