LightSwitch登录界面如何设置背景
来源:互联网 发布:手机行业进销存软件 编辑:程序博客网 时间:2024/05/17 22:30
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设置背景颜色个性化界面
- 设置自动更换主界面背景
- 奇偶数入座
- 网络IPC:套接字
- C语言中的经典小程序3
- 第四篇 随笔(小诗)
- [K/3Cloud] 树形单据体的应用说明
- LightSwitch登录界面如何设置背景
- 页面置换算法初步
- 符号symbol
- C++中的友元小结
- nfs 初步攻略
- 黑马程序——工厂模式
- Struts2中使用FreeMarker充当表现层
- java学习第一天注意事项(转子百度java吧)
- freemarker中空值 null的处理 ?exists ?default("")