# .NET and More > WPF, WCF, WF >  Convert a Winform Application to WPF bit by bit?

## 12padams

I have been developing a game simulating the use of another operating system called "ShiftOS" in VB.Net with winforms. The desktop is a full screen borderless form overlapping the users real desktop and the game has around 15 other forms as programs within ShiftOS so far but this nunber will dramatically increase over time.

Due to some graphical limitations I am running into people from this forum have recommended I convert my project over to WPF. I would like to do this step by step. For example lets say I want to convert over the clock application. Would it be possible for me to simply open a new WPF form, copy over the controls and code then tweak everything until it runes properly? From that point could I then just remove winform controls and put in the WPF controls one by one? 

What I'm asking here is: "Can I slowly convert a Winform project to WPF bit by bit rather than rewriting everything from scratch". Also I couldn't find a form load event in WPF, where do you your form load events?

Also is there any WPF control that is similar to the winforms panel?

Thanks I advance for your help.

----------


## szlamany

WPF is a totally different beast.  Even "events" have different signatures.  The entire event model is different.

The form itself is created in a XAML file - similar in looks to HTML.

I cannot see how you could migrate parts.

----------


## 12padams

Everything seems totally different. For example I can't figure out what to do with:


```
Public skinclosebuttonstyle As ImageLayout = ImageLayout.Stretch
```

Apparently ImageLayout is not defined... What would I do there?

----------


## szlamany

Like I said - it's totally different.  The whole framework that it talks to is different.

http://msdn.microsoft.com/en-us/libr...v=vs.110).aspx

It took me quite a while - and a lot of research (and one helpful book) to get started with a UI in WPF.

----------


## 12padams

I'm not a programmer and don't have time to do a whole rewrite of ShiftOS and learn an entire new language. The only reason I was going to convert to WPF was because I had a few graphical bugs and transparency problems in my game. Is there some other way I could fix this issue I had in this thread without converting to WPF: http://www.vbforums.com/showthread.p...rency-problems

Is converting an entire game over to WPF just to fix a few minor graphic bugs a bad idea? Are there any other ways around this?

----------


## boops boops

I think converting your app bit by bit to WPF could turn out to be a piece of cake. Admittedly I haven't tried it yet :Big Grin: . 

The idea is this. Make a WPF window to show the title bar, control buttons and border. Many of the details, in particular the project references, could be the same as in my "shaped form" example  (see sig. link). You may want to take advantage of the WPF Grid and StackPanel control for the layout of the title bar. For example, add 2 Row definitions to the default Grid, and put a StackPanel to hold the title bar and its buttons in the top row. The rest of the WPF window (row 2 of the Grid) will be filled by a WindowsFormsHost, which you will find in the WPF Designer Toolbox. In the WPF code, you declare an instance of your Form and make it the Child of the host, e.g.

vb.net Code:
Class MainWindow      Private Sub MainWindow_Initialized(sender As Object, e As System.EventArgs) Handles Me.Initialized        Dim child As New WindowsApplication2.Form1 With {.TopLevel = False}        WindowsFormsHost1.Child = child    End Sub End Class
Not that the form must have TopLevel = False. Obviously, there will be plenty of details to sort out but once you have done that for one form and one skin, the rest should be relatively plain sailing. I just tried this out with a test Form containing a combobox, a few buttons and a picturebox full of dancing mice and everything worked as intended.

BB

----------


## szlamany

Google for this and see how others have mixed win and wpf forms

mix winform and wpf

----------


## sapator

I always though that WPF slow as hell but that is just my opinion. Now i am taking some seminars in the biggest software company of Greece. They stopped using WPF on their software solutions because of the heavy performance issues, so that is a good sign that i personally shouldn't be using WPF. I would be using another graphic solution other than MS stuff anyhow. There was one that supported C# but can't recall the name.It's quite famous.

----------


## szlamany

My WPF U I is a prototype to show investors.  With funding this will be rewritten.

----------

