//File:Window.xaml.vb Imports System Imports System.IO Imports System.Windows Imports System.Windows.Controls Imports System.Windows.Markup Namespace WpfApplication1.LoadXamlResource Public Class LoadXamlResource Inherits Window Public Sub New() Title = "Load Xaml Resource" Dim uri As New Uri("pack://application:,,,/LoadXamlResource.xml") Dim stream As Stream = Application.GetResourceStream(uri).Stream Dim el As FrameworkElement = TryCast(XamlReader.Load(stream), FrameworkElement) Content = el Dim btn As Button = TryCast(el.FindName("MyButton"), Button) If btn IsNot Nothing Then AddHandler btn.Click, AddressOf ButtonOnClick End If End Sub Private Sub ButtonOnClick(sender As Object, args As RoutedEventArgs) Console.WriteLine(args.Source.ToString()) End Sub End Class End Namespace