Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. Finally started doing some WPF...

Finally started doing some WPF...

Scheduled Pinned Locked Moved The Lounge
csharpquestionlearningwpfwinforms
57 Posts 26 Posters 5 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Lost User

    Ian Shlasko wrote:

    1. Forget everything you know about interfaces and design tiers. WPF is a completely different paradigm.
    2. Learn to love XAML. It's weird and awkward at first, but once you get used to it, it's magic.
    3. In a perfect world, your code-behind should NEVER* have to refer to a GUI control. Don't even assign names to your controls unless you need to refer to them from a trigger or storyboard.

    1. Forget that you are programmer. Now you are computer graphics maker/script writer. 2. Learn not to hate XAML. 3. Write more code and XAML than necessary. Make it more and more complicated. But never write code-behind. Real man doesn't write code-behind!

    D Offline
    D Offline
    DiamondDave
    wrote on last edited by
    #42

    Alex Fr wrote:

    1. Learn to love XAML. It's weird
      and awkward at first, but once you get used to it, it's magic.

    I tried to get into WPF a couple of times and each time I was driven mad by the XAML bit. Coming from C++ and MFC, WinForms and C# seemed like a blessing when it came to making nice, functional interfaces. All (or at least most) of the properties for the components are in a nice properties box that you can modify to your hearts content. I don't really get why WPF seems to have gone backwards in usability by only having some properties exposed and everything else in the XAML, where you have to not only remember the name of the thing but also all of the properties. Don't get me wrong, I'm not trying to start an argument, I really just want someone to explain to me from a programming point of view, what makes WPF better than WinForms? Thanks Dave

    J B 2 Replies Last reply
    0
    • Sander RosselS Sander Rossel

      Started reading this huge book[^] (yes, VB and I'm proud of it! So don't start...) ;) Learning the "zammel" stuff, forgetting all I know about Events and Properties and thinking some very advanced controls are standard WPF stuff then finding out I have some DevExpress stuff installed... :doh: I've been planning this for months, and I finally started! Any tips for a WinForms going WPF programmer? (and no, I don't find this a programming question) :)

      It's an OO world.

      D Offline
      D Offline
      djdanlib 0
      wrote on last edited by
      #43

      Yeah, I have some tips. * Make something like Charles Petzold[^]'s XAML Cruncher. Well, try it, and then make your own. * Make a bunch of simple things with it before you bite off more than you can chew. It's really disappointing when you have this great idea for a GUI and then you drown in the XAML implementation because you didn't work through enough of the required ideas. * Read Sacha Barber's WPF articles[^] (scroll down to them.) His WPF code really sets a good standard. * Get yourself a copy of Expression Blend, if you can afford it. If you can't, at least get the express edition of Visual Studio for Windows Phone development, that has it. Then you can really play with these things in a GUI that was truly made for XAML development, and see how it all works. * Don't let this one scare you: It feels like a lower level than WinForms in some ways. You don't have to think about it often, but when you want to change the way it looks or feels, you'll get a good look at the guts. It has more guts than WinForms or MFC or anything else in @favorite_framework. Seriously. You'll have to think in terms of "What are the basic elements that compose this UI element" sometimes. Things as simple as a Button are made of borders and decorators and content presenters. A ScrollBar is broken down into its components. And just fuhgeddaboutit when you want to style a DataGrid until you've successfully styled less complex controls. Finally, don't listen to everything everyone tells you about it. Go, make things with it, and see for yourself how well it works for you.

      Sander RosselS 1 Reply Last reply
      0
      • A Alexander Voronin

        Tip: use C#

        D Offline
        D Offline
        djdanlib 0
        wrote on last edited by
        #44

        I'd say: Understand C#. Most WPF samples are for C#. At least know enough so you can translate it to VB, if you really bet the farm on VB.

        1 Reply Last reply
        0
        • Sander RosselS Sander Rossel

          Started reading this huge book[^] (yes, VB and I'm proud of it! So don't start...) ;) Learning the "zammel" stuff, forgetting all I know about Events and Properties and thinking some very advanced controls are standard WPF stuff then finding out I have some DevExpress stuff installed... :doh: I've been planning this for months, and I finally started! Any tips for a WinForms going WPF programmer? (and no, I don't find this a programming question) :)

          It's an OO world.

          R Offline
          R Offline
          RonanC111
          wrote on last edited by
          #45

          become familiar with Expression Blend. It provides the easiest way by along shot to create animations in WPF. If your app has a good UX, all will be forgiven by your users! :)

          1 Reply Last reply
          0
          • L Lost User

            Ian Shlasko wrote:

            1. Forget everything you know about interfaces and design tiers. WPF is a completely different paradigm.
            2. Learn to love XAML. It's weird and awkward at first, but once you get used to it, it's magic.
            3. In a perfect world, your code-behind should NEVER* have to refer to a GUI control. Don't even assign names to your controls unless you need to refer to them from a trigger or storyboard.

            1. Forget that you are programmer. Now you are computer graphics maker/script writer. 2. Learn not to hate XAML. 3. Write more code and XAML than necessary. Make it more and more complicated. But never write code-behind. Real man doesn't write code-behind!

            R Offline
            R Offline
            RonanC111
            wrote on last edited by
            #46

            I amazed people are saying things like learn not to hate xaml? I think it is entirely intuitive, more so than windows forms!!!

            1 Reply Last reply
            0
            • A Abhinav S

              Naerling wrote:

              Any tips for a WinForms going WPF programmer? (and no, I don't find this a programming question)

              1. Do not, I repeat do not, go for the event programming model of Windows Form. 2) Always try and think about 'binding' properties.

              Too much of heaven can bring you underground Heaven can always turn around Too much of heaven, our life is all hell bound Heaven, the kill that makes no sound

              R Offline
              R Offline
              RonanC111
              wrote on last edited by
              #47

              whats wrong with the event programming?

              1 Reply Last reply
              0
              • C chaiguy1337

                My one tip is check out this tiny component I wrote to make my life easier in WPF. I call it hip:Link: http://hip.codeplex.com/[^] It allows you to define a binding in terms of a method or property in the code-behind, so you don't need to do ungodly crap in your XAML or define custom converters for every single binding. It makes things significantly easier and is dead simple to use. Seriously I use it all the time. It's open sourced too.

                Sad but true: 4/3 of Americans have difficulty with simple fractions. There are 10 types of people in this world: those who understand binary and those who don't. {o,o}.oO( Check out my blog! ) |)””’)          http://pihole.org/ -”-”-

                Sander RosselS Offline
                Sander RosselS Offline
                Sander Rossel
                wrote on last edited by
                #48

                Thanks! I'll take a look at it. At the source code too. No better learning school than live code :)

                It's an OO world.

                C 1 Reply Last reply
                0
                • J Justin Kalweit

                  The most productive feature of XAML: COPY PASTE EDIT. I've found that ANYTHING I want to do in XAML is documented on a blog somewhere, COPY PASTE EDIT. You can't COPY PASTE EDIT a screenshot of a WinForm. Also, don't be afraid to use the designer to drag and drop buttons, labels, textboxes, etc. from the Toolbox. Visual Studio will autogenerate working XAML for you, and usually the only XAML you need to add by hand is the databindings. Then COPY PASTE EDIT this autogenerated XAML to create the rest of your controls.

                  Sander RosselS Offline
                  Sander RosselS Offline
                  Sander Rossel
                  wrote on last edited by
                  #49

                  Justin Kalweit wrote:

                  Also, don't be afraid to use the designer to drag and drop buttons, labels, textboxes, etc. from the Toolbox.

                  I've heard the opposite sound too. I tried it at first, but it seemed weird... XAML sets the Height and Width Properties if you use this method, which means your possibilities for automatic scaling are none. So even when you drag/drop from the Toolbox you'd need to edit the XAML file. I really find it unbelievable that Microsoft auto-generates those Properties while a major part of WPF is to not use them so everything auto-scales :confused:

                  It's an OO world.

                  J 1 Reply Last reply
                  0
                  • Sander RosselS Sander Rossel

                    Thanks! I'll take a look at it. At the source code too. No better learning school than live code :)

                    It's an OO world.

                    C Offline
                    C Offline
                    chaiguy1337
                    wrote on last edited by
                    #50

                    No prob! It's actually pretty simple, so should make a good example. If you have any questions about how anything works I'm happy to answer them!

                    Sad but true: 4/3 of Americans have difficulty with simple fractions. There are 10 types of people in this world: those who understand binary and those who don't. {o,o}.oO( Check out my blog! ) |)””’)          http://pihole.org/ -”-”-

                    1 Reply Last reply
                    0
                    • D djdanlib 0

                      Yeah, I have some tips. * Make something like Charles Petzold[^]'s XAML Cruncher. Well, try it, and then make your own. * Make a bunch of simple things with it before you bite off more than you can chew. It's really disappointing when you have this great idea for a GUI and then you drown in the XAML implementation because you didn't work through enough of the required ideas. * Read Sacha Barber's WPF articles[^] (scroll down to them.) His WPF code really sets a good standard. * Get yourself a copy of Expression Blend, if you can afford it. If you can't, at least get the express edition of Visual Studio for Windows Phone development, that has it. Then you can really play with these things in a GUI that was truly made for XAML development, and see how it all works. * Don't let this one scare you: It feels like a lower level than WinForms in some ways. You don't have to think about it often, but when you want to change the way it looks or feels, you'll get a good look at the guts. It has more guts than WinForms or MFC or anything else in @favorite_framework. Seriously. You'll have to think in terms of "What are the basic elements that compose this UI element" sometimes. Things as simple as a Button are made of borders and decorators and content presenters. A ScrollBar is broken down into its components. And just fuhgeddaboutit when you want to style a DataGrid until you've successfully styled less complex controls. Finally, don't listen to everything everyone tells you about it. Go, make things with it, and see for yourself how well it works for you.

                      Sander RosselS Offline
                      Sander RosselS Offline
                      Sander Rossel
                      wrote on last edited by
                      #51

                      djdanlib wrote:

                      * Read Sacha Barber's WPF articles[^] (scroll down to them.) His WPF code really sets a good standard.

                      Reading Sacha's articles is always a great tip :thumbsup:

                      djdanlib wrote:

                      Don't let this one scare you: It feels like a lower level than WinForms in some ways.

                      Well, that's the fun part isn't it? :laugh: Thanks for the great tips!

                      It's an OO world.

                      1 Reply Last reply
                      0
                      • Sander RosselS Sander Rossel

                        Justin Kalweit wrote:

                        Also, don't be afraid to use the designer to drag and drop buttons, labels, textboxes, etc. from the Toolbox.

                        I've heard the opposite sound too. I tried it at first, but it seemed weird... XAML sets the Height and Width Properties if you use this method, which means your possibilities for automatic scaling are none. So even when you drag/drop from the Toolbox you'd need to edit the XAML file. I really find it unbelievable that Microsoft auto-generates those Properties while a major part of WPF is to not use them so everything auto-scales :confused:

                        It's an OO world.

                        J Offline
                        J Offline
                        Justin Kalweit
                        wrote on last edited by
                        #52

                        Yeah, most of the UI in my apps are basically data entry forms or displays, and most of the fields are short, 25-50 chars. They actually work better when the size is set explicitly, for example if the user maximizes a window, it usually doesn't make since for a text box to span the entire screen. Occasionally I need a control to scale, so I simply remove the Width property manually. But in general, I use the designer to set my sizes and positions.

                        Sander RosselS 1 Reply Last reply
                        0
                        • J Justin Kalweit

                          Yeah, most of the UI in my apps are basically data entry forms or displays, and most of the fields are short, 25-50 chars. They actually work better when the size is set explicitly, for example if the user maximizes a window, it usually doesn't make since for a text box to span the entire screen. Occasionally I need a control to scale, so I simply remove the Width property manually. But in general, I use the designer to set my sizes and positions.

                          Sander RosselS Offline
                          Sander RosselS Offline
                          Sander Rossel
                          wrote on last edited by
                          #53

                          That's cool. To each his own and I see your point. But I was thinking on forgetting Height and Width Properties and use their Minimum and Maximum variants. But using the designer just doesn't work that way. I'd have to set those manually anyhow. Although perhaps having some XAML generated and then editing that isn't such a bad idea :)

                          It's an OO world.

                          1 Reply Last reply
                          0
                          • D DiamondDave

                            Alex Fr wrote:

                            1. Learn to love XAML. It's weird
                              and awkward at first, but once you get used to it, it's magic.

                            I tried to get into WPF a couple of times and each time I was driven mad by the XAML bit. Coming from C++ and MFC, WinForms and C# seemed like a blessing when it came to making nice, functional interfaces. All (or at least most) of the properties for the components are in a nice properties box that you can modify to your hearts content. I don't really get why WPF seems to have gone backwards in usability by only having some properties exposed and everything else in the XAML, where you have to not only remember the name of the thing but also all of the properties. Don't get me wrong, I'm not trying to start an argument, I really just want someone to explain to me from a programming point of view, what makes WPF better than WinForms? Thanks Dave

                            J Offline
                            J Offline
                            James Lonero
                            wrote on last edited by
                            #54

                            From a programming point of view, it is more painful (and more challenging). From a user point of view, it looks cooler, even with the useless animations.

                            1 Reply Last reply
                            0
                            • D DiamondDave

                              Alex Fr wrote:

                              1. Learn to love XAML. It's weird
                                and awkward at first, but once you get used to it, it's magic.

                              I tried to get into WPF a couple of times and each time I was driven mad by the XAML bit. Coming from C++ and MFC, WinForms and C# seemed like a blessing when it came to making nice, functional interfaces. All (or at least most) of the properties for the components are in a nice properties box that you can modify to your hearts content. I don't really get why WPF seems to have gone backwards in usability by only having some properties exposed and everything else in the XAML, where you have to not only remember the name of the thing but also all of the properties. Don't get me wrong, I'm not trying to start an argument, I really just want someone to explain to me from a programming point of view, what makes WPF better than WinForms? Thanks Dave

                              B Offline
                              B Offline
                              BubingaMan
                              wrote on last edited by
                              #55

                              "what makes WPF better than WinForms" Flexibility. The ability to make any control look like you want it to look with only a few lines of xaml. Easy animation. I also love the decoupling of the actual GUI and the "gui logic". Through the mvvm pattern, I literally never (with a few exotic exceptions) have to deal with controls directly. All I deal with is controllers, business calls and presentation models. I feel like it simply results in a much better structured and layered application. The XAML specifies how it looks on screen, based on the state of a presentationmodel. In code, all I need to do is maintain the state of that model and everything on screen will automagically adjust to changes. And if the user makes changes in the GUI, the model likewise automagically gets updated and from there you do whatever you want. What's not to like? I fell in love with it from day one.

                              1 Reply Last reply
                              0
                              • Sander RosselS Sander Rossel

                                Started reading this huge book[^] (yes, VB and I'm proud of it! So don't start...) ;) Learning the "zammel" stuff, forgetting all I know about Events and Properties and thinking some very advanced controls are standard WPF stuff then finding out I have some DevExpress stuff installed... :doh: I've been planning this for months, and I finally started! Any tips for a WinForms going WPF programmer? (and no, I don't find this a programming question) :)

                                It's an OO world.

                                I Offline
                                I Offline
                                ilovecashmere
                                wrote on last edited by
                                #56

                                Make your life easy, learn all you can about Dependency Properties. Everything else is cake from there. Binding, Controls, UI... It's all Based on the abilities of the Dispatcher. Learn that and everything will be easy(er).

                                Sander RosselS 1 Reply Last reply
                                0
                                • I ilovecashmere

                                  Make your life easy, learn all you can about Dependency Properties. Everything else is cake from there. Binding, Controls, UI... It's all Based on the abilities of the Dispatcher. Learn that and everything will be easy(er).

                                  Sander RosselS Offline
                                  Sander RosselS Offline
                                  Sander Rossel
                                  wrote on last edited by
                                  #57

                                  Thanks for the tip. Haven't looked into it yet, but certainly will do so soon :)

                                  It's an OO world.

                                  1 Reply Last reply
                                  0
                                  Reply
                                  • Reply as topic
                                  Log in to reply
                                  • Oldest to Newest
                                  • Newest to Oldest
                                  • Most Votes


                                  • Login

                                  • Don't have an account? Register

                                  • Login or register to search.
                                  • First post
                                    Last post
                                  0
                                  • Categories
                                  • Recent
                                  • Tags
                                  • Popular
                                  • World
                                  • Users
                                  • Groups