WindowsPhone XML文件异步加载示例

WindowsPhone 的 XML 文件加载小 Demo,功能不复杂,但胜在思路清晰、结构简单。用XmlReader读取本地 XML 文件,逻辑比较直接,适合刚接触 WindowsPhone 开发的朋友练手。

加载过程是异步的,界面不卡顿,用的是Deployment.Current.Dispatcher.BeginInvoke来回调 UI 更新,体验还挺流畅。你可以把它改成加载网络 XML,思路是一样的。

XML 结构不算复杂,做数据绑定也方便。比如你想把 XML 里的商品列表展示到ListBox里,加几行代码就能跑通。如果你写过Flex或者ActionScript的 XML 绑定,这种方式你会觉得熟悉。

想了解 XML 加载的其他方式,可以看看这些:

如果你刚好在做WindowsPhone的小项目,或者对XML 数据展示这块还不太熟,可以把这个 Demo 拉下来看看,改一改、跑一跑,快就能掌握门道。

zip
WindowsPhoneLoadingXMLFileDemo.zip 预估大小:32个文件
folder
WindowsPhoneLoadingXMLFileDemo 文件夹
file
WindowsPhoneLoadingXMLFileDemo.suo 35KB
folder
WindowsPhoneLoadingXMLFileDemo 文件夹
file
Background.png 3KB
file
SplashScreenImage.jpg 9KB
folder
obj 文件夹
folder
Debug 文件夹
file
WindowsPhoneLoadingXMLFileDemo.dll 12KB
file
MainPage.g.i.cs 3KB
file
WindowsPhoneLoadingXMLFileDemo.g.resources 3KB
file
DesignTimeResolveAssemblyReferences.cache 21KB
file
App.g.cs 2KB
file
DesignTimeResolveAssemblyReferencesInput.cache 7KB
file
WindowsPhoneLoadingXMLFileDemo.pdb 30KB
file
WindowsPhoneLoadingXMLFileDemo.csproj.FileListAbsolute.txt 4KB
folder
TempPE 文件夹
file
XapCacheFile.xml 2KB
file
App.g.i.cs 2KB
file
MainPage.g.cs 3KB
file
MainPage.xaml 2KB
folder
Properties 文件夹
file
WMAppManifest.xml 2KB
file
AppManifest.xml 207B
file
AssemblyInfo.cs 1KB
file
WindowsPhoneLoadingXMLFileDemo.csproj.user 218B
file
Carmakers.xml 382B
file
MainPage.xaml.cs 1KB
file
App.xaml 863B
file
App.xaml.cs 5KB
file
ApplicationIcon.png 2KB
file
WindowsPhoneLoadingXMLFileDemo.csproj 5KB
folder
Bin 文件夹
folder
Debug 文件夹
file
WindowsPhoneLoadingXMLFileDemo.dll 12KB
file
Background.png 3KB
file
WindowsPhoneLoadingXMLFileDemo.xap 15KB
file
WindowsPhoneLoadingXMLFileDemo.pdb 30KB
file
AppManifest.xaml 429B
file
ApplicationIcon.png 2KB
file
WindowsPhoneLoadingXMLFileDemo.sln 1KB
zip 文件大小:76.93KB