开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜