Articles → LIGHT SWITCH 2011 → Adding Silverlight control in lightswitch 2011

Adding Silverlight control in lightswitch 2011






























Software requirement











Prerequisite knowledge















Why we need custom control in lightswitch?





Table creation


Picture showing design view of LoginInformation table

Click to Enlarge




Login screen


Picture showing the design view of login screen in Lightswitch

Click to Enlarge




Add Silverlight library project type














Picture showing a pop up to select Silverlight version.

Click to Enlarge







Picture showing the project structure once project is created

Click to Enlarge


Add password control


Picture showing PasswordControl XAML file in project explorer window

Click to Enlarge





<UserControl x:Class="MyControl.PasswordControl"
   xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
   xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
   xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
   xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
   mc:Ignorable="d"     
   d:DesignHeight="40" d:DesignWidth="210">
   <Grid x:Name="LayoutRoot" Background="White">
      <PasswordBox x:Name="PasswordCtrl" Width="200" Height="30"                      
         ></PasswordBox>
   </Grid>
</UserControl>



Add binding to password control






<PasswordBox x:Name="PasswordCtrl" x:FieldModifier="public" Width="200" Height="30"  
   Password="{Binding Path=Screen.LoginInformationProperty.LoginPassword,Mode=TwoWay}"></PasswordBox>



Add custom control in lightswitch screen




Picture showing how control is changed to custom control

Click to Enlarge



Picture showing the property window for login password control

Click to Enlarge



Picture showing a popup window for adding Silverlight control in Lightswitch application

Click to Enlarge




Save value in database




Picture showing the window for adding records when we run the application

Click to Enlarge




Output


Picture showing the record list as an output

Click to Enlarge


Posted By  -  Karan Gupta
 
Posted On  -  Saturday, June 16, 2012

Query/Feedback


Your Email Id  
 
Subject 
 
Query/FeedbackCharacters remaining 250