Prev | Current Page 161 | Next

Matthew MacDonald

"Pro WPF with VB 2008: Windows Presentation Foundation with .NET 3.5"

It looks something
like this:
Partial Public Class Application
Inherits System.Windows.Application
Public Shared Sub Main()
Dim app As New Application
app.InitializeComponent()
app.Run()
End Sub
Public Sub InitializeComponent()
Me.StartupUri = New System.Uri("Window1.xaml", System.UriKind.Relative)
End Sub
End Class
If you??™re really interested in seeing the custom application class that the XAML template
creates, look for the Application.g.vb file in the obj\Debug folder inside your project directory.
The only difference between the automatically generated code shown here and a custom
application class that you might create on your own is that the automatically generated class
uses the StartupUri property instead of setting the MainWindow property or passing the main
window as a parameter to the Run() method. You??™re free to create a custom application class
that uses this approach, so long as you use the same URI format. You need to create a relative
Uri object that names a XAML document that??™s in your project. (This XAML document is compiled
and embedded in your application assembly as a BAML resource. The resource name is
the name of the original XAML file. In the previous example, the application contains a
resource named Window1.xaml with the compiled XAML.)
nNote The URI system you see here is an all-purpose way to refer to resources in your application.


Pages:
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173