0
votes

I know, I know, before any of you answer that WPF and Winforms are different, I already know that. We're using Csla so all of our code is properly separated. I only need to redo the UI and I need a good way to get the UI from Winforms over to Xaml. Just the form. I'm not talking about any code or anything. I'd just like the raw dialog box and controls to be converted. A textbox in Winforms is a textbox in Xaml. I wouldn't expect any custom controls or anything else. Our app has been using native .NET controls for this reason.

So, my question is. Does anyone know a way to convert a Winforms dialog box to a Xaml dialog box? I.e., take the winforms designer file and convert it to Xaml. All I want is as many of the raw controls as possible, such as labels, textboxes, etc. No code behind, no databinding, no custom controls, etc.

Our app has hundreds of dialog boxes and if I can get the something with just the controls on the form it would save us literally thousands of hours manually recreating each dialog box.

1
Problem with this approach is that winforms' layout is X,Y based (therefore fixed size, fixed position by definition), while WPF is resolution independent and relative-position based by default. If you're rewriting you should take the time and do it right.Federico Berasategui

1 Answers

2
votes

Yes and no.

Yes, it's possible, essentially by copying and pasting WinForms Designer generated code and doing a series of Find-and-Replace operations to replace WinForms namespacing and names with WPF's equivalent (e.g. Top/Left with WPF's Margin). Granted this won't be XAML (instead it will resemble the XAML-generated *.g.cs files) but it will be WPF, but it won't be user-friendly (as @highCore mentioned, because you're not taking advantage of WPF's layout and resolution-independence mechanisms).

But the time taken to reimplement forms and dialogs in XAML really isn't that much - maybe 10-20 minutes for a moderately complicated form, provided you're already competent in XAML and are adopting modern techniques like MVVM, and doing things by hand instead of using a designer (because designers never seem to get things right...)