开发者

Convert XAML WPF Window to WinForm

开发者 https://www.devze.com 2023-02-10 11:01 出处:网络
Is there any utility or converter to convert XAML开发者_StackOverflow中文版 WPF window to .Net 2.0 Windows forms form?No, and there\'s unlikely to be anything like this; WPF and WinForms are disparate

Is there any utility or converter to convert XAML开发者_StackOverflow中文版 WPF window to .Net 2.0 Windows forms form?


No, and there's unlikely to be anything like this; WPF and WinForms are disparate frameworks, a WPF UI can't really be converted to a WinForms UI due to differences in UI composition, layout differences, different positioning systems, etc.


There is no tool to convert it across. It might be worth using an ElementHost to load WPF components in WPF, that way you don't need to convert and can re-use WPF components. If you have a WPF window you would need to convert this to a UserControl to work.

EDIT:

.Net 2 code to load WPF control

    string dllPath = "C:\\ProjectsTest\\TestSolution\\ActiveXUser\\bin\\Debug\\TestControl.dll";
if (!File.Exists(dllPath)) {
    return;
}

string versionInformation = null;
versionInformation = Environment.Version.Major.ToString() + Environment.Version.Minor;

Assembly loadedAssembly = Assembly.LoadFile(dllPath);

Type[] mytypes = loadedAssembly.GetTypes();

Type t = mytypes[1];
Object obj = Activator.CreateInstance(t);

versionInformation = Environment.Version.Major.ToString() + Environment.Version.Minor;
this.Panel1.Controls.Add(obj);


Maybe you could use this Xaml library for WinForms?

https://winformsxaml.codeplex.com

0

精彩评论

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