"Pro WPF with VB 2008: Windows Presentation Foundation with .NET 3.5"
">Command 1
...
You can then access the Tag property in your code: Private Sub DoSomething(ByVal sender As Object, ByVal e As RoutedEventArgs) Dim tag As Object = CType(sender,FrameworkElement).Tag MessageBox.Show(CType(tag,String)) End Sub CHAPTER 6 n DEPENDENCY PROPERTIES AND ROUTED EVENTS 163 Tunneling Events Tunneling events work the same as bubbling events, but in the opposite direction. For example, if MouseUp was a tunneled event (which it isn??™t), clicking the image in the fancy label example would cause MouseUp to fire first in the window, then in the Grid, then in the StackPanel, and so on until it reaches the actual source, which is the image in the label. Tunneling events are easy to recognize because they begin with the work Preview. Furthermore, WPF usually defines bubbling and tunneling events in pairs. That means if you find a bubbling MouseUp event, you can probably also find a tunneling PreviewMouseUp event. The tunneling event always fires before the bubbling event, as shown in Figure 6-3. Figure 6-3. Tunneling and bubbling events To make life more interesting, if you mark the tunneling event as handled the bubbling event won??™t occur.