Windows 8 Store Apps Learning (59) Lock Screen

Source: Internet
Author: User
Tags tostring xmlns

Introduced

Re-imagine the Windows 8 Store Apps lock screen

Login lock screen, get the current program's lock screen permission, remove from the lock screen

Send badge or text to lock screen

Bind multiple tile of an app to a lock screen

Custom lock Screen Picture

Example

1. Demonstrates how to login to the lock screen, get the current program's lock screen permission, remove from the lock screen

Lockscreen/accesslockscreen.xaml

<page x:class= "XamlDemo.LockScreen.AccessLockScreen" xmlns= "http://schemas.microsoft.com/winfx/2006/xaml/pres Entation "xmlns:x=" Http://schemas.microsoft.com/winfx/2006/xaml "xmlns:local=" Using:XamlDemo.LockScreen "xmlns :d = "http://schemas.microsoft.com/expression/blend/2008" xmlns:mc= "http://schemas.openxmlformats.org/" markup-compatibility/2006 "mc:ignorable=" D "> <grid background=" Transparent "> <stackpanel margin= "0 0 0" > <textblock name= "lblmsg" fontsize= "14.667"/> & Lt Button Name= "btnrequestaccess" content= "Request Login lock Screen" margin= "0 0 0" click= "Btnrequestaccess_click"/> &L T
    
            Button Name= "Btngetaccessstatus" content= "get lock screen permission for current program" margin= "0 0 0" click= "Btngetaccessstatus_click"/>
    
        <button name= "btnremoveaccess" content= "removed from the lock screen" margin= "0 0 0" click= "Btnremoveaccess_click"/> </StackPanel> &LT;/GRID&GT </Page>

Lockscreen/accesslockscreen.xaml.cs

* * Demonstrates how to log in to the lock screen, get the current program's lock screen permission, remove * * NOTE: * In order to request the lock screen permission, need background task support "push notice" or "Control channel" * * using System;
Using Windows.ApplicationModel.Background;
Using Windows.UI.Xaml;
    
Using Windows.UI.Xaml.Controls; Namespace Xamldemo.lockscreen {public sealed partial class Accesslockscreen:page {public ACCESSLOCKSCR Een () {this.
        InitializeComponent ();
            Private async void Btnrequestaccess_click (object sender, RoutedEventArgs e) {try     {//request to the System login lock screen, pop-up confirmation dialog box//Require background task support "push notification" or "control channel", or throw an exception// Cannot run in emulator//if Backgroundaccessstatus is not equal to Unspecified, the dialog box will not appear even if Requestaccessasync () is called, requiring the user to go to "settings"
    
                To add or remove the lock screen application backgroundaccessstatus status = await Backgroundexecutionmanager.requestaccessasync ();
    * * Backgroundaccessstatus-lock screen permission for current app * Unspecified-User not selected             * Denied-Rejected by the user * allowedwithalwaysonrealtimeconnectivity-for allow, and support real-time connection, even if the low battery
    
                * Allowedmayuseactiverealtimeconnectivity-for allow, and support real-time connection, but if the low power can not be connected in real time * * Lblmsg.text = "Requestaccessasync ():" + status.
            ToString (); The catch (Exception ex) {lblmsg.text = ex.
            ToString (); 
            }} private void Btngetaccessstatus_click (object sender, RoutedEventArgs e) {try {//Get the current application's lock-screen permission backgroundaccessstatus status = Backgroundexecutionmanager .
                Getaccessstatus (); Lblmsg.text = "Getaccessstatus ():" + status.
            ToString (); The catch (Exception ex) {lblmsg.text = ex.
            ToString ();
         } private void Btnremoveaccess_click (object sender, RoutedEventArgs e) {   try {//Remove the current application from the lock screen backgroundexecutionmanager.removeaccess ();
            Lblmsg.text = "removeaccess ()"; The catch (Exception ex) {lblmsg.text = ex.
            ToString (); }
        }
    }
}

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.