Preface:
In these days, I will update my blog one week. If you have any shortcomings, please advise me more .....
By a 15-year-old programmer
Body:
The following figure shows the implementation results and technologies used:
The main function is to get the information in the current account and modify the user's profile picture. Although it is simple, it is quite difficult for me as a newbie.ProgramFrame, fileopenpicker, and other related knowledge are used in. For details, refer to explain.
First, let's talk about frame,
Frame is actually a framework. The frame usage is very simple. I used only one of its attributes (content) and one method (navigate) in this program. The source code is displayed first:
Grid grid =NewGrid (); frame frame1=NewFrame (); frame1.content= Grid;// Set the frame contentFrame frame2 =NewFrame (); frame2.natigate (Typeof(Mainpage ),This);// Set the display interface. The mainpage content is specified here.
The natigate method of frame has two parameters. The first parameter is a type object and specifies the form to be loaded. The format is "namespace +. + form Class Name: it is assumed that a button should be clicked under the window form to load the Windows form under the namespace for the frame,CodeWrite as follows:
Frame frame =NewFrame (); frame. natigate (type. GetType (Typeof(Window ).Namespace)+ Window1), this );
The second parameter indicates the parent form.
Next, let's talk about fileopenpicker,
Fileopenpicker is a class used to open some libraries in the computer. It can be used to easily open the image library, download the library, and music library. We still use code to speak:
fileopenpicker videopicker = New fileopenpicker {viewmode = pickerviewmode. thumbnail, suggestedstartlocation = pickerlocationid. videoslibrary, filetypefilter ={ " . MP4 ", " . MPEG ", " . MPEG ", " . WMV ", " . moV " }};
Viewmode indicates the display mode of fileopenpicker, whether it is thumbnail or list, suggestedstartlocation indicates fileopenpicker to open the library, and filetypefilter indicates the extension.
Next, display it in an image:
Fileopenpicker imagepicker = New Fileopenpicker {viewmode = Pickerviewmode. thumbnail, suggestedstartlocation = Pickerlocationid. pictureslibrary, filetypefilter = { " . Jpg " , " . Jpge " , " . BMP " , " . PNG " }; Storagefile Image = Await imagepicker. picksinglefileasync (); If (Image! = Null ) {Windows. system. USERPROFILE. setaccountpictureresult result = Await windows. system. USERPROFILE. userinformation. setaccountpicturesasync ( Null , Image,Null ); If (Result = Windows. system. USERPROFILE. setaccountpictureresult. Success) {rootpage. showcontent ( " Set successfully! " );} Else {Rootpage. showcontent ( " Setting failed! " );}
Note that the async keyword must be added to the front of the event to which the Code belongs. Also reference using Windows. Storage and
Using Windows. Storage. pickers
Finally, all the operations on the computer account are performed in the windows. system. USERPROFILE namespace. For details, click.
** Additional source code ************************
Https://skydrive.live.com/redir? Resid = f408a3d3df420664! 180 & authkey =! ADzK4h9Z7IiN-EE
***************************************
Source code is of low quality due to time issues .......