Results 1 to 11 of 11

Thread: Windows Form Vs WPF and XAML

  1. #1

    Thread Starter
    Member
    Join Date
    Aug 2013
    Posts
    53

    Windows Form Vs WPF and XAML

    I am new to vb.net and have been trying out the Windows Form and the WPF.

    With the WPF, MS is enabling the developer to separate the Design of a form, from the Programming behind the form. The Design can be done manually or in Blend and the end result is XAML.

    I have two questions for the time being:
    1) Can a developer perform ALL the Design in VB, without bothering with XAML?
    2) What are the advantages of using XAML instead of VB?

    Thanks,
    John

  2. #2
    PowerPoster Evil_Giraffe's Avatar
    Join Date
    Aug 2002
    Location
    Suffolk, UK
    Posts
    2,555

    Re: Windows Form Vs WPF and XAML

    1) Theoretically this would be possible, yes, but it would be incredibly hard to do, and give you zero benefit whilst making your code harder to write. Pretend the answer is "No".
    2) The main benefit in my eyes is the separation of presentation (XAML) from the application logic (VB code). Being able to deal with these two areas separately and letting WPF's databinding system do the menial work of keeping changes in sync is a very big win. Another good thing is its declarative style (as opposed to the imperative style you would normally end up with in VB code), which can save a ton of time.
    XAML can be a bit verbose with all its tags, but VS has pretty good tools for working with it, so you don't need to type it all by hand. As well, there is Blend that you mention, so you're aware of that.

    Note that you can get the separation of presentation and logic with WinForms, but it doesn't push you down that route, and it is very easy to mix up logic and presentation concerns in the code-behind of a form. There are libraries and frameworks that can sit on top of WinForms to help guide you away from that, or you can just write your code in a MV* architecture (usually MVP is the easiest, although MVC is doable. Even MVVM is doable - I once wrote a library to help do MVVM in WinForms as part of a long term transition to WPF at a previous company).

  3. #3

    Thread Starter
    Member
    Join Date
    Aug 2013
    Posts
    53

    Re: Windows Form Vs WPF and XAML

    Thanks for the reply. In other words embrace WPF and XAML.

    I downloaded Blend yesterday, but it looked a bit hostile!

    Can you suggest some very simple tutorials that would show WPF & XAML in action?

    Thanks,
    John

  4. #4
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: Windows Form Vs WPF and XAML


    *** 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
    Member
    Join Date
    Aug 2013
    Posts
    53

    Re: Windows Form Vs WPF and XAML

    Quote Originally Posted by szlamany View Post

    Thanks a lot.

    I am four days into mine.

    I skimmed over the articles you sent over. They seem exactly what I am looking for.

    John

  6. #6
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: Windows Form Vs WPF and XAML

    Yeah WPF is the way to go moving forward, but it does have quite a steep learning curve initially (especially for people coming from WinForms). My one bit of advice for people new to WPF would be don't bother dragging and dropping controls onto your form/window in the designer - just learn to write the XAML by hand. It gives you so much more control over layout and how things resize or move around when the window is resized. Oh and also if you get annoyed with the text being a bit blurry in WPF apps like I did, you can use this style to make all TextBlocks use the new rendering mode in .NET 4.0 that makes it much sharper:

    Code:
    <Window x:Class="MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525" UseLayoutRounding="True" SnapsToDevicePixels="True">
       
        <Window.Resources>
            <Style TargetType="TextBlock" >
                <Setter Property="TextOptions.TextFormattingMode" Value="Display" />
            </Style>
        </Window.Resources>
        
        <Grid>
        .....
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  7. #7

    Thread Starter
    Member
    Join Date
    Aug 2013
    Posts
    53

    Re: Windows Form Vs WPF and XAML

    Chris thanks for your advice which I will follow.

    Being new to VS I can opt for WPF, since I do not have any attachments.
    John

  8. #8
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: Windows Form Vs WPF and XAML

    Are you using VS 2012?

    It appears to be written in WPF - as does IE10 - although I am guessing...

    *** 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

  9. #9
    Frenzied Member MattP's Avatar
    Join Date
    Dec 2008
    Location
    WY
    Posts
    1,227

    Re: Windows Form Vs WPF and XAML

    I would check out the Microsoft Design Toolbox. It's Silverlight oriented but you'll get a good look at XAML and good design principles if you go through the whole thing.
    This pattern in common to all great programmers I know: they're not experts in something as much as experts in becoming experts in something.

    The best programming advice I ever got was to spend my entire career becoming educable. And I suggest you do the same.

  10. #10
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: Windows Form Vs WPF and XAML

    Quote Originally Posted by szlamany View Post
    Are you using VS 2012?

    It appears to be written in WPF - as does IE10 - although I am guessing...
    VS 2010 was written in WPF - which is why issues such as the blurry text got addressed for .NET 4.0. WPF in .NET 3.5 wasn't great as it was very new - there's a video somewhere where the VS team explain that when they came to use it to make VS 2010 they got the WPF team to fix some of these problems. So presumably VS 2012 and 2013 are made in WPF as well.

    IE10 isn't made in WPF as its not even a .NET application
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  11. #11
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: Windows Form Vs WPF and XAML

    Well IE10 has a feel that must mean they talk to DirectX the same way - I'm not talking about rendering a DOM-page - I'm talking about how the outside UI of IE10 behaves - like the NEW TAB page with selections. That has a GRID-like feel to the layout.

    Or I just see XAML everywhere

    *** 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
  •  



Click Here to Expand Forum to Full Width