Convert a Winform Application to WPF bit by bit?-VBForums
Results 1 to 9 of 9

Thread: Convert a Winform Application to WPF bit by bit?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2010
    Posts
    102

    Convert a Winform Application to WPF bit by bit?

    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.

  2. #2
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    CT
    Posts
    15,907

    Re: Convert a Winform Application to WPF bit by bit?

    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.

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Mar 2010
    Posts
    102

    Re: Convert a Winform Application to WPF bit by bit?

    Everything seems totally different. For example I can't figure out what to do with:
    Code:
    Public skinclosebuttonstyle As ImageLayout = ImageLayout.Stretch
    Apparently ImageLayout is not defined... What would I do there?

  4. #4
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    CT
    Posts
    15,907

    Re: Convert a Winform Application to WPF bit by bit?

    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.

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Mar 2010
    Posts
    102

    Re: Convert a Winform Application to WPF bit by bit?

    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?

  6. #6
    PowerPoster boops boops's Avatar
    Join Date
    Nov 2008
    Location
    Holland/France
    Posts
    2,467

    Re: Convert a Winform Application to WPF bit by bit?

    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.

    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:
    1. Class MainWindow
    2.  
    3.     Private Sub MainWindow_Initialized(sender As Object, e As System.EventArgs) Handles Me.Initialized
    4.         Dim child As New WindowsApplication2.Form1 With {.TopLevel = False}
    5.         WindowsFormsHost1.Child = child
    6.     End Sub
    7.  
    8. 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

  7. #7
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    CT
    Posts
    15,907

    Re: Convert a Winform Application to WPF bit by bit?

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

    mix winform and wpf

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  8. #8
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    4,311

    Re: Convert a Winform Application to WPF bit by bit?

    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.
    Last edited by sapator; Jun 18th, 2014 at 06:07 PM.
    Slow as hell.

  9. #9
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    CT
    Posts
    15,907

    Re: Convert a Winform Application to WPF bit by bit?

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

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.