LightSwitch登录界面如何设置背景
来源:互联网 发布:企业邮箱域名备案 编辑:程序博客网 时间:2024/04/30 11:25
LightSwitch中登录窗口是系统自动提供的,同时不支持自定义登录接口,程序一运行,就显示一个大白屏,中间是登录名,密码及一个按钮,这个真的非常难看。对于登录后的界面(应用一些皮肤样式),真的难于忍受。自己来动手美化一下吧。
将LS切换到文件模式下,进入到client项目,找到UserCode下的Application.cs,在里面添加如下代码,原理是通过对象引用找到系统内置登录窗口中的容器对象,强行植入背景。代码如下:
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; public 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;//拉伸 // add image Grid grid = ((LoginPage)e.Content).Content as Grid; grid.Children.Insert(0, mylogo); // not Add, for background rootFrame.Navigated -= rootFrame_Navigated; } }}
运行一下。看一下效果
- LightSwitch登录界面如何设置背景
- LightSwitch登录界面如何设置背景
- A06_RelativeLayout_logIn_登录界面设置
- 如何把图片整合到war3的mpq文件中作为登录背景界面
- 如何测试登录界面
- ubuntu 11.10中修改登录界面背景
- 更改Fedora 17的登录界面背景
- tabhost如何设置背景
- notepad如何设置背景
- achartengine 如何设置背景
- 修改win7的登录界面背景与关机背景
- 登录界面的密码设置
- 用户登录界面的设置
- 用户登录界面的设置
- 个性化lightswitch登录屏幕(附源码)
- 个性化lightswitch登录屏幕(附源码)
- secureCRT设置背景颜色个性化界面
- 设置自动更换主界面背景
- linux设备驱动归纳总结(一):内核的相关基础概念
- LambdaProbe 监控Tomcat使用详解
- DNS负载均衡与CDN内容分发技术
- Android线程优先级设置方法
- linux设备驱动归纳总结(二):模块的相关基础概念
- LightSwitch登录界面如何设置背景
- 如何调试MFC中的内存泄漏
- QTP10.0录制web程序时,无法打开IE问题解析
- 喜欢海贼
- 败者树
- 详细讲解提高数据库查询效率的实用方法、外键关于性能【转】
- 什么是差分信号?
- QTP10.0下active screen无法捕捉图像与无法录制windows程序
- C++沉思录读书笔记(9,10章)-感想