通过这一节课,对数据绑定基本概念有更深的理解,掌握如何进行数据绑定,掌握如何对应用程序数据进行处理,了解几种网络访问方式。//出生年份&年龄的数值转换器//实现了INotifyPropertyChanged接口的Employe类UI标记绑定属性=”{BindingSource=*,Path=*,Mode=*,Converter=*,}”…/e.g.XAMLCodeTextBoxName=txbName3Text={BindingPath=Name,Mode=OneWay}Height=71Width=308/C#Codecanvas2.DataContext=employee;//ListBox数据模板演示注册DataChanged事件,将DataChangeHandler设置为用于漫游数据更改的处理程序voidInitHandlers(){Windows.Storage.ApplicationData.Current.DataChanged+=newTypedEventHandlerApplicationData,object(DataChangeHandler);}voidDataChangeHandler(Windows.Storage.ApplicationDataappData,objecto){}•ApplicationData.LocalSettings属性获取ApplicationDataContainer对象中的设置•ApplicationData.LocalFolder属性获取StorageFolder对象中的文件Windows.Storage.ApplicationDataContainerlocalSettings=Windows.Storage.ApplicationData.Current.LocalSettings;Windows.Storage.ApplicationDataContainerlocalFolder=Windows.Storage.ApplicationData.Current.LocalFolder;•ApplicationData.RoamingSettings属性可以获取设置•ApplicationData.RoamingFolder属性可以获取文件Windows.Storage.ApplicationDataContainerroamingSettings=Windows.Storage.ApplicationData.Current.RoamingSettings;Windows.Storage.ApplicationDataContainerroamingFolder=Windows.Storage.ApplicationData.Current.RoamingFolder;•使用ApplicationData.TemporaryFolder属性获取文件Windows.Storage.StorageFoldertemporaryFolder=ApplicationData.Current.TemporaryFolder;//简单设置localSettings.Values[exampleSetting]=HelloWindows;//组合设置Windows.Storage.ApplicationDataCompositeValuecomposite=newWindows.Storage.ApplicationDataCompositeValue();composite[intVal]=1;composite[strVal]=string;localSettings.Values[exampleCompositeSetting]=composite;//设置一个容器Windows.Storage.ApplicationDataContainercontainer=localSettings.CreateContainer(exampleContainer,Windows.Storage.ApplicationDataCreateDisposition.Always);if(localSettings.Containers.ContainsKey(exampleContainer)){localSettings.Containers[exampleContainer].Values[exampleSetting]=HelloWindows;}//简单设置roamingSettings.Values[exampleSetting]=HelloWorld;//组合设置Windows.Storage.ApplicationDataCompositeValuecomposite=newWindows.Storage.ApplicationDataCompositeValue();composite[intVal]=1;composite[strVal]=string;roamingSettings.Values[exampleCompositeSetting]=composite;//设置一个容器Windows.Storage.ApplicationDataContainercontainer=roamingSettings.CreateContainer(exampleContainer,Windows.Storage.ApplicationDataCreateDisposition.Always);if(roamingSettings.Containers.ContainsKey(exampleContainer)){roamingSettings.Containers[exampleContainer].Values[exampleSetting]=HelloWorld;}//简单设置Objectvalue=localSettings.Values[exampleSetting];//组合设置Windows.Storage.ApplicationDataCompositeValuecomposite=(Windows.Storage.ApplicationDataCompositeValue)localSettings.Values[exampleCompositeSetting];if(composite==null){}else{}//设置一个容器boolhasContainer=localSettings.Containers.ContainsKey(exampleContainer);boolhasSetting=false;if(hasContainer){hasSetting=localSettings.Containers[exampleContainer].Values.ContainsKey(exampleSetting);}//简单设置Objectvalue=roamingSettings.Values[exampleSetting];//组合设置Windows.Storage.ApplicationDataCompositeValuecomposite=(Windows.Storage.ApplicationDataCompositeValue)roamingSettings.Values[exampleCompositeSetting];if(composite==null){}else{}//设置一个容器boolhasContainer=roamingSettings.Containers.ContainsKey(exampleContainer);boolhasSetting=false;if(hasContainer){hasSetting=roamingSettings.Containers[exampleContainer].Values.ContainsKey(exampleSetting);}asyncvoidWriteTimestamp(){Windows.Globalization.DateTimeFormatting.DateTimeFormatterformatter=newWindows.Globalization.DatetimeFormatting.DateTimeFormatter(longtime);StorageFilesampleFile=awaitlocalFolder.CreateFileAsync(dataFile.txt,CreateCollisionOption.ReplaceExisting);awaitFileIO.WriteTextAsync(sampleFile,formatter.Format(DateTime.Now));}asyncvoidWriteTimestamp(){Windows.Globalization.DateTimeFormatting.DateTimeFormatterformatter=newWindows.Globalization.DatetimeFormatting.DateTimeFormatter(longtime);StorageFilesampleFile=awaitroamingFolder.CreateFileAsync(dataFile.txt,CreateCollisionOption.ReplaceExisting);awaitFileIO.WriteTextAsync(sampleFile,formatter.Format(DateTime.Now));}asyncvoidWriteTimestamp(){Windows.Globalization.DateTimeFormatting.DateTimeFormatterformatter=newWindows.Globalization.DatetimeFormatting.DateTimeFormatter(longtime);StorageFilesampleFile=awaittemporaryFolder.CreateFileAsync(dataFile.txt,CreateCollisionOption.ReplaceExisting);awaitFileIO.WriteTextAsync(sampleFile,formatter.Format(DateTime.Now));}asyncvoidReadTimestamp(){try{StorageFilesampleFile=awaitlocalFolder.GetFileAsync(dataFile.txt);Stringtimestamp=awaitFileIO.ReadTextAsync(sampleFile);}catch(Exception){}}asyncvoidReadTimestamp(){try{StorageFilesampleFile=awaitroamingFolder.GetFileAsync(dataFile.txt);Stringtimestamp=awaitFileIO.ReadTextAsync(sampleFile);}catch(Exception){}}asyncvoidReadTimestamp(){try{StorageFilesampleFile=awaittemporaryFolder.GetFileAsync(dataFile.txt);Stringtimestamp=awaitFileIO.ReadTextAsync(sampleFile);}catch(Exception){}}//删除简单设置localSettings.Values.Remove(exampleSetting);//删除组合设置localSettings.Values.Remove(