One thing that is still available, however, is the ToolBox. So drag a Button to the Window. Remember that this is not the Windows Forms Button, even though the name is the same. This Button is in the System.Windows.Controls namespace. Everything in that namespace is a WPF control.
Although Windows Forms gives you access to the Button properties, WPF and XAML give you an XML based description of everything about the Button.
<Button Margin="67,52,134,0"
Name="Button1"
Height="23"
VerticalAlignment="Top">
Button
</Button>
--------
Click Here to display the illustration
Click the Back button on your browser to return
--------
If you have delayed until now to become familiar with XML, this should be a wakeup call to get started.
The component properties are now expressed as XML attributes in the XAML code. And the Properties window has been redone too, complete with a progressive search box so you don't have to scroll back and forth to find the property you're looking for. There are so many new ones that this is a blessing!
--------
Click Here to display the illustration
Click the Back button on your browser to return
--------
Now drop a Label onto the Window. Try collapsing the XAML code window and zoom the Design pane to about 150%. Try moving and resizing the Label. Note that you can get precision far beyond Windows Forms with WPF.
--------
Click Here to display the illustration
Click the Back button on your browser to return
--------
The VB.NET part of the coding is done in separate file, in this case Window1.xaml.vb. Since nothing about the Window or the components in it is in the VB.NET code, the designer can handle part of the job and the programmer can do the rest.
Or ... Are there still jobs that the programmer has to do?
I decided to see if I could vary the opacity of a WPF Label component. The only way I could find to do the job was to reference the System.Windows.Forms namespace into the WPF application in order to gain access to a Timer component.
If you're confused about how to "reference a namespace" then here's a quick explanation. WPF and Windows Forms are completely different technical environments in the Microsoft world, so the System.Windows.Forms "namespace" isn't even available to WPF applications by default. That means that any objects in that namespace can't be used in a WPF application unless you take an extra step to make them available.
After starting a new WPF application, right-click the project in Solution Explorer and select Properties. Select the References tab. Notice that System.Windows.Forms is not in the References box. There are literally thousands of references that are possible (not all are included with Visual Studio - third parties make them too). If everything possible was referenced, your project would be bloated as much as the US federal budget. So only the ones that Microsoft has decided are very likely to be needed by your project are referenced by default.
To add a new reference, click the Add ... button and scroll to System.Windows.Forms and select it. Click OK. You should be able to access the Timer object and then the code that follows did the job just fine. But it was still something the programmer had to do that affected the appearance.
Here's the code:
Class Window1
Friend WithEvents myTimer As New System.Windows.Forms.Timer
Private Sub Button1_Click( _
ByVal sender As System.Object, _
ByVal e As System.Windows.RoutedEventArgs) _
Handles Button1.Click
myTimer.Interval = 100
myTimer.Start()
Label1.Content = "Hello From" & vbCrLf & "About Visual Basic"
Label1.FontSize = 24
Label1.Opacity = 0.5
End Sub
Private Sub myTimer_Tick( _
ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles myTimer.Tick
Label1.Opacity += 0.01
If Label1.Opacity > 1 Then Label1.Opacity = 0
End Sub
End Class
Part 2 of this series, XAML, WPF, and Namespaces, introduces one of the most fundamental concepts that you need to understand: Namespaces. The term 'namespace' always means about the same thing, but the way it's used changes quite a bit. Part 2 tells you how it's used in XAML and WPF.

