Teach you to create a simple Silverlight application using Visual Studio 2010

Source: Internet
Author: User
Tags xmlns silverlight visual studio visual studio 2010

Silverlight is a new way to create dynamic, compelling RIAs (Rich Internet application). This teaches you to create a simple Silverlight application.

1. Open vs, new project, select Silverlight Application template.

2. Name Mysimplesilverlightapplication, click OK.

3. In the pop-up dialog box, clear the "host Silverlight applications in new site" check box, click OK.

4. Your interface should be like this.

5. Drag four controls (2 labels, a text box, and a button).

6. The X:name property represents the name (or ID) of the Silverlight control. Make sure that the final code is like this:

<usercontrol x:class= "Mysimplesilverlightapplication.mainpage" 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" :D esignheight= "204" d:designwidth= "xmlns:datainput=" clr-namespace:system.windows.controls;assembly= System.Windows.Controls.Data.Input "> <grid x:name=" layoutroot "background=" white "height=" 186 "> < Datainput:label content= "My A-Silverlight App" height= "horizontalalignment=" left "margin=" 42,32,0,0 "Name=" Lbltitle "verticalalignment=" Top "width=" fontweight= "Bold"/> <button "click=" "Btnname_click" Greeting "height=" horizontalalignment= "left" margin= "42,115,0,0" name= "Btnname" verticalalignment= "Top" Width= " "/> <textbox height=" horizontalalignment= "left" margin= "104,72,0,0" name= "Txtbxname" VeRticalalignment= "Top" width= "163"/> <datainput:label content= "Name:" height= "horizontalalignment=" Margin= "42,72,0,0" name= "Lblname" verticalalignment= "Top" width= "a"/> </Grid> </UserControl>

The interface is like this:

7. Right-click MainPage.xaml to view the code.

8. Add code as follows:

Using System;
Using System.Collections.Generic;
Using System.Linq;
Using System.Net;
Using System.Windows;
Using System.Windows.Controls;
Using System.Windows.Documents;
Using System.Windows.Input;
Using System.Windows.Media;
Using System.Windows.Media.Animation;
Using System.Windows.Shapes;
    
Namespace Mysimplesilverlightapplication
{public
partial class Mainpage:usercontrol
{
public MainPage ()
{
InitializeComponent ();
}
    
private void Btnname_click (object sender,
RoutedEventArgs e)
{
string mynameprefix = "Length of Name:"; c23/>string myname = Txtbxname.text;
int mynamelength = 0;
Mynamelength = myname.length;
MessageBox.Show (Mynameprefix +
mynamelength.tostring ());
Btnname.content = "Goodbye";}}

9. F5 Test.

Add the Silverlight Web Part on the SharePoint site.

Author: csdn Blog Zhang Shihui

More Wonderful content: http://www.bianceng.cnhttp://www.bianceng.cn/webkf/Silverlight/

Related Article

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.