This blog post mainly introduces Setting Contract overview, basic principles of Setting Contract implementation, how to build Setting Contract, and Setting Contract best practices.
Setting Contract
Overview1) Setting Contract provides a quick and contextual immersive access experience in the current application; 2) Setting Contract is always available; 3) settings include always-available system settings, system proxy settings that allow users to control the application's access to system devices and functions, and settings specified by the current application; we can draw a super button from the right edge of the screen and select "Settings" to display the setting window. The settings window includes both application settings and system settings. 650) this. width = 650; "border =" 0 "alt =" "src =" http://www.bkjia.com/uploads/allimg/131228/1F6041358-0.png "/> for developers, you can use SettingCommand to provide entry points in the device panel, these entries are displayed at the top of the settings window, where "permission" and "comment and score"
[
Note: Only Windows
This entry point is available for apps approved by the App Store.]Two entry points
System provision. The bottom of the Setting panel includes the system-provided computer settings [volume, brightness, power supply, and other information].
Setting Contract
Implementation Principle650) this. width = 650; "border =" 0 "alt =" "src =" http://www.bkjia.com/uploads/allimg/131228/1F60425c-1.png "/> 1) register the CommandsRequested event in the settings Panel; 2) specify the SettingsCommand command in the callback function of the related setting event; 3) Add the SettingsCommand command to ApplicationCommands to make the command take effect in the setting panel;
How to Build Setting ContractAs mentioned above, how can we implement Setting Contract in an application? Step 1: register the CommandsRequested event. 650) this. width = 650; "border =" 0 "alt =" "src =" http://www.bkjia.com/uploads/allimg/131228/1F6043005-2.png "/> Step 2:
OnCommadsReqestedAdd the SettingsCommand command to the callback function. The SettingsCommand class constructor contains three parameters. 650) this. width = 650; "border =" 0 "alt =" "src =" http://www.bkjia.com/uploads/allimg/131228/1F60435O-3.png "/> three parameters are
SettingsCommandId[Set the command Id. this parameter is of the object type],
Label[Entry point display information in the control panel] and handler [operation performed to trigger this entry point. This parameter type is UICommandInvokedHandler]. In the callback function: 650) this. width = 650; "border =" 0 "alt =" "src =" http://www.bkjia.com/uploads/allimg/131228/1F6045124-4.png "/> when we declare that the SettingsCommand object sets the handler parameter, you can use
Lambda
ExpressionYou can also declare
UICommandInvokedHandlerSet the handler parameter. Where
UICommandInvokedHandler
DelegateThe object must pass a type
IUICommand. 650) this. width = 650; "border =" 0 "alt =" "src =" http://www.bkjia.com/uploads/allimg/131228/1F6041T8-5.png "/> the code can be: 650) this. width = 650; "border =" 0 "alt =" "src =" http://www.bkjia.com/uploads/allimg/131228/1F604MZ-6.png "/>
Note:: You can also click Process Code declaration in a certain entry point on the settings panel.
SettingsFlyoutAnd add a custom control to the control panel. The code can be as follows: 650) this. width = 650; "border =" 0 "alt =" "src =" http://www.bkjia.com/uploads/allimg/131228/1F6044R1-7.png "/> we can set
SettingsFlyoutThe Content, HeaderBrush, HeaderText, and other attributes of the object.
AboutUserControlCustom Controls for users. We can use
Right-click the application solution=>
Add=>
Add new itemIn the pop-up panel, find
User ControlAnd Add. 650) this. width = 650; "border =" 0 "alt =" "src =" http://www.bkjia.com/uploads/allimg/131228/1F604I56-8.png "/> then we can set the display style and information for the custom control. The code can be as follows: 650) this. width = 650; "border =" 0 "alt =" "src =" http://www.bkjia.com/uploads/allimg/131228/1F6045L9-9.png "/> Step 3: add the SettingsCommand command to ApplicationCommands, make the entry point take effect in the settings panel. 650) this. width = 650; "border =" 0 "alt =" "src =" http://www.bkjia.com/uploads/allimg/131228/1F6041222-10.png "/> after completing these three steps, we can run our own applications to see how the settings panel has changed. Running Effect: 650) this. width = 650; "border =" 0 "alt =" "src =" http://www.bkjia.com/uploads/allimg/131228/1F60440W-11.png "/> we can see that the two entry points we added are already displayed in the settings panel. Click an entry point to perform the preset operations. 650) this. width = 650; "border =" 0 "alt =" "src =" http://www.bkjia.com/uploads/allimg/131228/1F6044236-12.png "/> shows the content set in the custom control.
Build Setting Contract
Best practices1) Set Application-related features in Setting Contract; 2) do not include the task flow in Setting Contract; 3) add no more than four settings; 4) integrate rarely used configuration items; 5) provide portals for commonly used configuration items; 6) set levels should not exceed the two poles; 7) when the user changes the settings, the application will immediately reflect the setting; 8) provide the same setting experience for the same type of setting; 9) each setting item should have a concise and easy-to-understand description; 10) do not use settings to navigate to other parts of the application. 11) the recommended controls in the settings Panel include ToggleSwitch, Button, HyperlinkButton, TextBox, RadioButton, and CheckBox;