Fire up Visual Studio 2010 and click File in Visual C#

Maker QR-Code in Visual C# Fire up Visual Studio 2010 and click File

1. Fire up Visual Studio 2010 and click File
QR Generator In Visual C#.NET
Using Barcode creation for .NET Control to generate, create QR image in Visual Studio .NET applications.
www.OnBarcode.com
QR Code 2d Barcode Scanner In Visual C#
Using Barcode recognizer for VS .NET Control to read, scan read, scan image in .NET framework applications.
www.OnBarcode.com
Project, as I am doing in Figure 13-1.
Matrix 2D Barcode Generator In Visual C#.NET
Using Barcode drawer for .NET Control to generate, create Matrix 2D Barcode image in .NET framework applications.
www.OnBarcode.com
DataMatrix Maker In Visual C#.NET
Using Barcode generator for .NET Control to generate, create ECC200 image in VS .NET applications.
www.OnBarcode.com
Figure 13-1. Create a new project.
Create EAN / UCC - 14 In Visual C#.NET
Using Barcode generation for Visual Studio .NET Control to generate, create GS1-128 image in Visual Studio .NET applications.
www.OnBarcode.com
Encode Barcode In C#.NET
Using Barcode maker for Visual Studio .NET Control to generate, create Barcode image in .NET applications.
www.OnBarcode.com
2. Select Silverlight Application from the list, name the application
Code-39 Generator In C#
Using Barcode drawer for .NET Control to generate, create Code 3/9 image in .NET applications.
www.OnBarcode.com
MSI Plessey Generation In C#.NET
Using Barcode drawer for VS .NET Control to generate, create MSI Plessey image in VS .NET applications.
www.OnBarcode.com
DefaultOutOfBrowserProject, and make certain your settings match what I have in Figure 13-2.
QR Code Recognizer In Visual Basic .NET
Using Barcode reader for .NET framework Control to read, scan read, scan image in Visual Studio .NET applications.
www.OnBarcode.com
QR Code JIS X 0510 Drawer In Objective-C
Using Barcode creation for iPad Control to generate, create Quick Response Code image in iPad applications.
www.OnBarcode.com
WRITING A SILVERLIGHT 4 OUT-OF-BROWSER APPLICATION
ANSI/AIM Code 128 Decoder In Java
Using Barcode recognizer for Java Control to read, scan read, scan image in Java applications.
www.OnBarcode.com
GTIN - 13 Drawer In None
Using Barcode printer for Font Control to generate, create European Article Number 13 image in Font applications.
www.OnBarcode.com
Figure 13-2. Select Silverlight Application and name the project DefaultOutOfBrowserProject.
Printing Barcode In Java
Using Barcode creation for Java Control to generate, create Barcode image in Java applications.
www.OnBarcode.com
Reading European Article Number 13 In None
Using Barcode decoder for Software Control to read, scan read, scan image in Software applications.
www.OnBarcode.com
3. Because you don t really need an ASP web site for an OOB application, go ahead and
Data Matrix ECC200 Drawer In None
Using Barcode creator for Microsoft Word Control to generate, create ECC200 image in Office Word applications.
www.OnBarcode.com
Draw Denso QR Bar Code In None
Using Barcode creation for Font Control to generate, create QR-Code image in Font applications.
www.OnBarcode.com
uncheck Host the Silverlight application in a new web site option in the New Silverlight Application, as I have done in Figure 13-3.
Drawing European Article Number 13 In VB.NET
Using Barcode creator for .NET framework Control to generate, create EAN-13 image in .NET framework applications.
www.OnBarcode.com
Drawing Code 3 Of 9 In None
Using Barcode creator for Font Control to generate, create Code 3/9 image in Font applications.
www.OnBarcode.com
Figure 13-3. Uncheck the option to Host the Silverlight application in a new Web site.
Barcode Scanner In VS .NET
Using Barcode decoder for .NET Control to read, scan read, scan image in Visual Studio .NET applications.
www.OnBarcode.com
EAN-13 Printer In Objective-C
Using Barcode encoder for iPhone Control to generate, create EAN-13 image in iPhone applications.
www.OnBarcode.com
4. Switch over to Blend and add some visual elements to the application. The fastest way to do
this is to right-click MainPage.xaml in the Solution Explorer and left-click Open in Expression Blend, as I am doing in Figure 13-4.
Figure 13-4. Open MainPage.xaml in Expression Blend. Because Visual Studio 2010 makes default Silverlight applications 400 300, click the [UserControl] in Blend s Objects and Timeline panel, as I am doing in Figure 13-5. Move over to the Layout bucket of the Properties panel and change the Width to 800 and the Height to 600, as I have done in Figure 13-6.
Figure 13-5. Select the [UserControl] in Blend s Objects and Timeline panel.
WRITING A SILVERLIGHT 4 OUT-OF-BROWSER APPLICATION
Figure 13-6. Change the Width and Height properties to 800 and 600 respectively. The first thing to do is add a background Rectangle that will appear to gray out anything in the application. Then we need to add a default Silverlight Button control on top of that that reads Install Application. We will then group them both into a container. It is going to be this container that we will programmatically make Collapsed only if the application already has been installed. Let s do that now.
1. Create a Rectangle that is the same size as the [UserControl] (800 600), as I have done
in Figure 13-7.
Figure 13-7. Make a Rectangle the same size as the application.
2. Change the Rectangle to have a black Fill and an opacity of 65%, so users can see a little of
the application through it when it is visible.
3. Click the Button control from the toolbar and draw a Silverlight Button in the center of the
artboard.
4. In the Properties panel name the Button InstallBtn.
5. In the Common Properties bucket of the Properties panel, change the Button s Content
property to Install Application, so you have what I have in Figure 13-8.
Figure 13-8. Your application should look like this at this stage.
6. Now we need to group the background and Button into a Container grid. In the Objects and
Timeline panel, Ctrl+click both the Rectangle and the Install button.
7. Right-click and left-click Group Into
Grid, as I am doing in Figure 13-9.
Figure 13-9. Group the Rectangle and Button into a Grid.
WRITING A SILVERLIGHT 4 OUT-OF-BROWSER APPLICATION
8. Double-click the newly created Grid in the Objects and Timeline panel and name it
InstallContainer, so that your Objects and Timeline panel looks like what I have in Figure 13-10.
Figure 13-10. Your Objects and Timeline panel should now look like this. Now that you have done this, you can press Ctrl+Shift+B to build the application. Switch back over to Visual Studio 2010 to set this as an OOB application and wire up the functionality that will determine whether the InstallContainer should be shown or not.
1. Now that you have put in all the install visuals, right-click the Project (not the Solution) in the
Solution Explorer and left-click Properties, as I am doing in Figure 13-11.
Figure 13-11. Select Properties in Visual Studio 2010 s Solution Explorer.
2. Click Enable running application out of the browser, as I have done in Figure 13-12.
Figure 13-12. Set the application to run out of the browser.
3. Now click the Out-of-Browser Settings button, also shown in Figure 13-12. 4. Check Require elevated trust when running outside the browser, as I have done in
Figure 13-13, and then click OK.
Figure 13-13. Require Elevated Trust for the application. Now we can go ahead and add the code that will show or hide the InstallContainer.
WRITING A SILVERLIGHT 4 OUT-OF-BROWSER APPLICATION
1. Open MainPage.xaml.cs and right under the IntializeComponent(); call type Loaded +=
and hit the Tab key twice to create a loaded handler. Your code should now look like the following code: namespace DefaultOutOfBrowserProject { public partial class MainPage : UserControl { public MainPage() { InitializeComponent(); Loaded += new RoutedEventHandler(MainPage_Loaded); } void MainPage_Loaded(object sender, RoutedEventArgs e) { throw new NotImplementedException(); } } }
When viewing the XAML for a UserControl, you can right-click it in Visual Studio 2010 to open its codebehind file (see Figure 13-14).
Figure 13-14. Right-click the XAML of a UserControl to be taken to its code-behind file.
2. Now you can check to see whether the file is installed, and if it is then you can collapse the
InstallContainer. See the following code: void MainPage_Loaded(object sender, RoutedEventArgs e) { if (App.Current.InstallState == InstallState.Installed) { InstallContainer.Visibility = Visibility.Collapsed; } }
At this point if you were to run the application, you would in fact see the install button because the application has not yet been installed. But currently if we clicked the install button, nothing would happen. Let s fix that now.
1. Under the code that sets the visibility of the InstallContainer type InstallBtn.Click += and
press the Tab key twice. This creates the Click EventHandler for you. See my code here: void MainPage_Loaded(object sender, RoutedEventArgs e) { if (App.Current.InstallState == InstallState.Installed) { InstallContainer.Visibility = Visibility.Collapsed; } InstallBtn.Click += new RoutedEventHandler(InstallBtn_Click); } void InstallBtn_Click(object sender, RoutedEventArgs e) { throw new NotImplementedException(); }
Download from Wow! eBook <www.wowebook.com>
2. Now erase the default code and put in the code that installs the application, as I do here:
void InstallBtn_Click(object sender, RoutedEventArgs e) { App.Current.Install(); } We need to make the application check for updates when it s started. Fortunately for us Microsoft and the Silverlight team have made that quite easy for us. Let s add that now:
1. Under the InitializeComponent(); call, add a call to the static CheckAndDownloadAsync()
call, as I do here: public MainPage() { InitializeComponent(); App.Current.CheckAndDownloadUpdateAsync(); Loaded += new RoutedEventHandler(MainPage_Loaded); }
Copyright © OnBarcode.com . All rights reserved.