Professional Documents
Culture Documents
Applications Using
Microsoft® Visual
Studio® 2008
Module 12: Delivering Dynamic Content with
Microsoft Silverlight
• Overview of Microsoft Silverlight
• Architecture of Silverlight
• Handling Events
• Attribute syntax
<Canvas>
<Rectangle Width="150"Height="75"Fill="Red"/>
</Canvas>
• Text syntax
<Canvas>
<TextBlock Text="Hello"/>
</Canvas>
Handling Events
• Define a handler in the XAML file
• Write the handler in the code-behind file for the XAML file
[Visual C#]
public void Page_Loaded(object o, EventArgs e)
{
...
Button1.MouseLeftButtonDown += new
MouseEventHandler(OnClick);
}
[Visual Basic]
Protected Sub Page_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles Me.Load
...
AddHandler Button1.MouseLeftButtonDown, _
AddressOf OnClick
End Sub
Demonstration: Displaying Video Files in a
Silverlight Application
• Add a video file to a Silverlight application
Logon information
Event Handling
Page.xaml.cs or
Page.xaml.vb
Lab Web
Application
Lab Review
Review Questions
• How can you create a square XAML object?
• Tools