How to set the background on the lightswitch logon Interface

Source: Internet
Author: User

In lightswitch, the logon window is automatically provided by the system and does not support custom logon interfaces,ProgramA big white screen is displayed, with the login name, password, and button in the middle. This is really ugly. It is really unbearable for the login interface (applying some skin styles. Do it yourself.

 

Switch ls to file mode, enter the client project, find application. CS under usercode, and add the followingCodeThe principle is to find the container object in the system's built-in login window through object reference and forcibly implant the background. The Code is as follows:

 

Using system; using system. LINQ; using system. io; using system. io. isolatedstorage; using system. collections. generic; using Microsoft. lightswitch; using Microsoft. lightswitch. framework. client; using Microsoft. lightswitch. presentation; using Microsoft. lightswitch. presentation. extensions; using system. windows. controls; using system. reflection; using Microsoft. lightswitch. runtime. shell. internal. implementation; Pu BLIC partial class application {frame rootframe = NULL; partial void application_initialize () {Microsoft. lightswitch. threading. dispatchers. main. begininvoke () => {rootframe = (PAGE) (contentpresenter) system. windows. application. current. rootvisual ). content ). content as frame; If (rootframe! = NULL) rootframe. navigated + = new system. windows. navigation. navigatedeventhandler (rootframe_navigated) ;});} void rootframe_navigated (Object sender, system. windows. navigation. navigationeventargs e) {If (E. content is loginpage) {// prepare image, that is laying in the resources folder as embedded resource system. windows. media. imaging. bitmapimage image = new system. windows. media. imaging. bitmapimage (); image. setsource (assembly. getexecutingassembly (). getmanifestresourcestream (this. getType (), "bg.png"); image mylogo = new image () {source = image, stretch = system. windows. media. stretch. uniform}; mylogo. setvalue (grid. columnspanproperty, 5); mylogo. setvalue (grid. rowspanproperty, 7); mylogo. stretch = system. windows. media. stretch. fill; // stretch // Add image grid = (loginpage) E. content ). content as grid; grid. children. insert (0, mylogo); // not add, for background rootframe. navigated-= rootframe_navigated ;}}}

Run it. Check the effect

The background image was modified based on the qq sl version.

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.