A damn at Han's Windows Phone Book notes (20, 21, 22: isolated storage)

Source: Internet
Author: User

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 );}}
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.