//File:Window.xaml.vb Imports System Imports System.Collections.Generic Imports System.Linq Imports System.Text Imports System.Windows Imports System.Windows.Controls Imports System.Windows.Data Imports System.Windows.Documents Imports System.Windows.Input Imports System.Windows.Media Imports System.Windows.Media.Imaging Imports System.Windows.Navigation Imports System.Windows.Shapes Imports System.IO Imports System.Windows.Markup Namespace WpfApplication1 Public Partial Class MainWindow Inherits Window Public Sub New() InitializeComponent() End Sub Private Sub btnViewXaml_Click(sender As Object, e As RoutedEventArgs) File.WriteAllText("YourXaml.xaml", txtXamlData.Text) Dim myWindow As Window = Nothing Try Using sr As Stream = File.Open("YourXaml.xaml", FileMode.Open) myWindow = DirectCast(XamlReader.Load(sr), Window) myWindow.ShowDialog() End Using Catch ex As Exception MessageBox.Show(ex.Message) End Try End Sub Private Sub Window_Loaded(sender As Object, e As RoutedEventArgs) txtXamlData.Text = "" & vbLf & "" & vbLf & "" & vbLf & "" End Sub Private Sub Window_Closed(sender As Object, e As EventArgs) File.WriteAllText("YourXaml.xaml", txtXamlData.Text) End Sub End Class End Namespace