Create WPF forms dynamically using XAML files
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 开发者_StackOverflow中文版is a really dumb question, but I was wondering that it might save me the burden of writing code to create them automatically.
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.
精彩评论