简体   繁体   中英

Convert XAML WPF Window to WinForm

是否有实用程序或转换器将XAML WPF窗口转换为.Net 2.0 Windows表单形式?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM