tags:

views:

13

answers:

1

I am trying to write a program to dynamically create WPF forms. Is it possible to create XAML file and make .NET framework load them automatically?

I don't know if this is a really dumb question, but I was wondering that it might save me the burden of writing code to create them automatically.

A: 

XamlReader can do this very easily.

var stream = File.OpenRead(xamlFileName);
//cast to whatever is the toplevel element in XAML
var loadedElement = (Window)XamlReader.Load(stream); 

There is also a lot of resources on this subject on the web.

Marek