1

Is there any utility or converter to convert XAML WPF window to .Net 2.0 Windows forms form?

Saw
  • 6,199
  • 11
  • 53
  • 104
  • 1
    i don't think there are any.. and even if there are.. i wonder how could they flatten the control hierarchy of WPF to winform controls... – Shekhar_Pro Feb 15 '11 at 18:54
  • You're right, but i need the basic layout, or the 'figure' – Saw Feb 15 '11 at 18:58
  • Couldn't you simply embed your WPF control into WinForms' windows using [ElementHost](http://msdn.microsoft.com/en-us/library/system.windows.forms.integration.elementhost.aspx) ? – digEmAll Feb 15 '11 at 19:00
  • But the problem is that i'm using .net 2.0!! :) – Saw Feb 15 '11 at 19:04

3 Answers3

3

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.

Judah Gabriel Himango
  • 58,906
  • 38
  • 158
  • 212
  • I see, the main reason is the different composition way in WPF, but i need a utility to give me a rough WinForm contains the controls in the nearest way they are in the WPF window – Saw Feb 15 '11 at 19:21
  • I'm afraid there's nothing like that to my knowledge, and I tend to be privy on these sort of things. – Judah Gabriel Himango Feb 17 '11 at 15:52
2

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);
Community
  • 1
  • 1
Tom Dudfield
  • 3,077
  • 2
  • 25
  • 39
0

Maybe you could use this Xaml library for WinForms?

https://winformsxaml.codeplex.com

Simon Egli
  • 31
  • 2