WPF VB.Net

    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:custom="clr-namespace:WpfApplication1"  
    Title="gotfocusLostfocusEffectUsingEvent" Height="400" Width="450"
    >
  
    
      
        
        
        
      
    

            GotFocus="OnGotFocusHandler"
        LostFocus="OnLostFocusHandler">Click Or Tab To Give Keyboard Focus
            GotFocus="OnGotFocusHandler"
        LostFocus="OnLostFocusHandler">Click Or Tab To Give Keyborad Focus
  


//File:Window.xaml.vb
Imports System
Imports System.Windows
Imports System.Windows.Controls
Imports System.Windows.Data
Imports System.Windows.Media
Imports System.Windows.Input
Namespace WpfApplication1
  Public Partial Class Window1
    Inherits Window
    Public Sub New()
      InitializeComponent()
    End Sub
    Private Sub OnGotFocusHandler(sender As Object, e As RoutedEventArgs)
      Dim tb As Button = TryCast(e.Source, Button)
      tb.Background = Brushes.Red
    End Sub
    Private Sub OnLostFocusHandler(sender As Object, e As RoutedEventArgs)
      Dim tb As Button = TryCast(e.Source, Button)
      tb.Background = Brushes.White
    End Sub
  End Class
End Namespace