Isolated Storage
Isolated is called because the data of one app cannot be accessed by another app.
Although isolatedstoragesettings has a save method, it is not necessary to call it. BecauseProgramData will be stored during close or deactive operations. The only time the Save method was called, data was lost because the app crashed and exited.
After the app is upgraded, data in isolated storage is retained. After the app is uninstalled, the data is deleted.
There is no size limit for isolated storage, and it is only limited by the storage size of mobile phones.
Color Selection Control
The shared/colorpicker directory has a good color selection control.
Use custom Fonts
< Textblock Fontfamily = "Fonts/pendule_ornamental.ttf # pendule ornamental" Opacity = ". 1"> <! -- It's important not to have whitespace between the runs! --> < Run X : Name = "Timebackgroundrun"> 88: 88 </ Run > < Run X : Name = "Secondsbackgroundrun"> 88 </ Run > </ Textblock >
First, add the font file to the project. The syntax in XAML is:
Font File Path # font name
The font file TTF can be directly opened and installed in windows.
Value Converter
It is mainly used to convert one type into another type in data binding.
An ivalueconverter interface must be implemented as a converter type, that is, the convert and convertback methods.
If convertback is not required for one-way binding, the convertback method can directly return dependencyproperty. unsetvalue.
The following is an example of implementing these two methods:
Public object Convert ( Object Value, Type Targettype, Object Parameter, Cultureinfo Culture ){ Datetimeoffset Date = ( Datetimeoffset ) Value; // Return a custom format Return Date. localdatetime. to1_datestring () + "" + Date. localdatetime. tow.timestring ();} Public object Convertback ( Object Value, Type Targettype, Object Parameter,Cultureinfo Culture ){ Return Dependencyproperty . Unsetvalue ;}
You can directly specify the converter in XAML. Before specifying the converter, you need to create an instance of the converter in the resource dictionary.
<Phone:Phoneapplicationpage. Resources> <Local:DateconverterX:Key= "Dateconverter"/> </Phone:Phoneapplicationpage. Resources>
Then reference in XAML:
<Textblock Text= "{BindingModified,Converter= {StaticresourceDateconverter}}"/>
If you want to specify parameter and culture in XAML, write as follows:
File read/write
Public String Filename { Get ;Set ;} Public void Savecontent ( String Content ){ Using ( Isolatedstoragefile Userstore = Isolatedstoragefile . Getuserstoreforapplication ()) Using ( Isolatedstoragefilestream Stream = userstore. createfile ( This . Filename )) Using ( Streamwriter Writer = New Streamwriter (Stream) {writer. Write (content );}} Public String Getcontent (){ Using ( Isolatedstoragefile Userstore = Isolatedstoragefile . Getuserstoreforapplication ()){ If (! Userstore. fileexists ( This . Filename )){ Return string . Empty ;} Else { Using (Isolatedstoragefilestream Stream = userstore. openfile ( This . Filename, Filemode . Open )) Using ( Streamreader Reader = New Streamreader (Stream )){ Return Reader. readtoend ();}}}} Public void Deletecontent (){ Using ( Isolatedstoragefile Userstore =Isolatedstoragefile . Getuserstoreforapplication () {userstore. deletefile ( This . Filename );}}