开发者

Create WPF forms dynamically using XAML files

开发者 https://www.devze.com 2023-01-08 04:29 出处:网络
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 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

精彩评论

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