Windows.Controls.Button
Friend WithEvents txtAnswer As System.Windows.Controls.TextBox
Private _contentLoaded As Boolean
' Load the BAML.
Public Sub InitializeComponent() _
Implements IComponentConnector.InitializeComponent
If _contentLoaded Then
Return
End If
_contentLoaded = True
CHAPTER 2 n XAML 55
Dim resourceLocater As New System.Uri( _
"/EightBall;component/window1.xaml", System.UriKind.Relative)
System.Windows.Application.LoadComponent(Me, resourceLocater)
End Sub
' Hook up each control.
Sub System_Windows_Markup_IComponentConnector_Connect( _
ByVal connectionId As Integer, ByVal target As Object) _
Implements System.Windows.Markup.IComponentConnector.Connect
If (connectionId = 1) Then
Me.txtQuestion = CType(target, System.Windows.Controls.TextBox)
Return
End If
If (connectionId = 2) Then
Me.cmdAnswer = CType(target, System.Windows.Controls.Button)
AddHandler Me.cmdAnswer.Click, AddressOf Me.cmdAnswer_Click
Return
End If
If (connectionId = 3) Then
Me.txtAnswer = CType(target,System.Windows.Controls.TextBox)
Return
End If
Me._contentLoaded = true
End Sub
End Class
When the XAML-to-BAML compilation stage is finished, Visual Studio uses the appropriate
language compiler to compile your code and the generated partial class files. In the case of
a VB application, it??™s the vbc.
Pages:
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166