Mega Code Archive
Launch a window with defined XAML
//File:Window.xaml.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.IO;
using System.Windows.Markup;
namespace WpfApplication1
{
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void btnViewXaml_Click(object sender, RoutedEventArgs e)
{
File.WriteAllText("YourXaml.xaml", txtXamlData.Text);
Window myWindow = null;
try
{
using (Stream sr = File.Open("YourXaml.xaml", FileMode.Open))
{
myWindow = (Window)XamlReader.Load(sr);
myWindow.ShowDialog();
}
}
catch (Exception ex)
{ MessageBox.Show(ex.Message); }
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
txtXamlData.Text =
"\n"
+ "\n"
+ "\n"
+ "";
}
private void Window_Closed(object sender, EventArgs e)
{
File.WriteAllText("YourXaml.xaml", txtXamlData.Text);
}
}
}