What should a C# developer know before using WPF [closed] - c#

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 11 years ago.
I'am more a sysadmin and a webmaster than a developer, but sometime I develop, including C# principally using Winform (and optionally GTK+).
I've started few weeks ago a WPF project, and it seem really powerful, but at start I feel like a hen who found a knife! There is so many difference!
stackoverflow abounds about topic like that, and I've read carefully some who are similar like:
Hidden features of WPF and XAML?
What all should an expert C#/.Net/WPF developer know?
But, when somebody start with WPF from Winform, What are the differences to which he must pay attention?
[EDIT]
What about some advices/links for LINQ with WPF?
What about some advices/links WPF Navigation?

WPF is completely different from other systems.
I have a few years of WinForms, Win32 and web programming experience, and I believe my web programming experience helped the most.
As for books, "Windows Presentation Foundation Unleashed" from Adam Nathan, Sams Publishing has helped me tremendously.

to getting started with WPF a design pattern Model View ViewModel (MVVM) would be important to know.
also I would recommend Adam Nathan WPF4 book. I think it's great one!

Thank you all, but all this is a bit diffuse, so I made a resources compilation and add some things by my own, please tell me what you think (or improve, I make it Community Wiki)
Strangely no one has talked about LINQ which seemed to be a central element of this technology.
Another thing that seems important to know given the time I lost, is not to use the WPF navigation system that doesn't seems to work properly from numerous sources I've read. So, it seem important to use a navigation framework, like Magellan.
And the routed event system seem to be an important point to look at in WPF, if somebody have some interesting resources about it, please add to this post.
RTFM
Windows Presentation Foundation
WPF Documentation Samples
.NET Language-Integrated Query for XML Data
.NET Framework Developer Center - LINQ
Software
In the Box – MVVM Training
Caliburn Micro: A Micro-Framework for WPF, Silverlight and WP7
Blog posts
sachabarber.net
MVVM for Dummies
Deep drive into WPF graphics internals Part 1
Building WPF Applications with the Page Navigation framework
Videos
MVVM Design Pattern NDC2009
The Code Project
Articles by Sacha Barber
WPF: A Beginner's Guide Part 1 of n
WPF: A Beginner's Guide Part 2 of n
WPF: A Beginner's Guide Part 3 of n
WPF: A Beginner's Guide Part 4 of n
WPF: A Beginner's Guide Part 5 of n
WPF: A Beginner's Guide Part 6 of n
Magellan: An MVC-powered Navigation Framework for WPF
Books:
Windows Presentation Foundation Unleashed (WPF)
WPF 4 Unleashed (the same as precedent but for WPF4)
Other Stack Overflow topics
Hidden features of WPF and XAML?
What all should an expert C#/.Net/WPF developer know?
Questions every good .NET developer should be able to answer?

I agree with Arseny, learning MVVM is core to learning WPF properly. It isn't a niche thing - when applied properly it can make your code cleaner, simpler and promotes decoupling and unit testing.
There is a very nice video here which explains both the concept and implementation:
Jonas Follesø explains the MVVM Design Pattern. In the video the guy is talking about Silverlight but the implementation in WPF is pretty much identical.
Once you've watched the video, and you're happy with the basics of WPF you could do alot worse than adopt a framework to take much of the heavy lifting and plumbing off your hands. I highly reccommend Caliburn Micro. This will lead you down the path of best practice by encouraging you to use MVVM but will also take care of much of the coding detail for you. The documentation on the site is a bit thin on the ground but there are a number of tutorials there that are being steadily added to.
For example, when following MVVM you would typcially have a View (e.g. a window) and ViewModel (a C# class). If you had a textbox on the view which contained an order number, you would have a corresponding property on your ViewModel called OrderNumber. Using a WPF Binding expression:
<TextBox x:Name="OrderNumber" Text="{Binding OrderNumber}" />
the textbox would be bound to the property on your ViewModel so that when either the textbox or the property changes, the other automatically updates. Using a framework like Caliburn Micro you don't have to write any binding expressions, it uses a simple convention based approach. In the previous example, if your textbox was called OrderNumber and your ViewModel property was called OrderNumber Caliburn assumes they must be the same thing and automatically binds them for you.
<TextBox x:Name="OrderNumber" />
As above, your XAML becomes much simpler, and leaves you to focus on getting the job done. I wish I'd found a framework like this earlier before I started churning out lots of my own ViewModelBase classes, ViewLocaters etc.

I also suggest Sacha Barber's blog and all its WPF related articles in codeproject. This guy rocks!

The most important thing a Winforms/C# developer should know/accept is that WPF is very different from winforms and Winforms way of doing things is not the correct way of doing things in WPF.
I have seen a lot of WinForms developers using events/delegates and threads to solve every each and every problem instead of using Binding, commands, triggers etc.

Related

C# User interface [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 9 years ago.
I have been programming in java for a couple of years now. Not long ago i decided that it was time to make a change and learn C#.
Now since it both visual studio and C# is new to me i have decided that since i have to learn it anyway i might learn the newest tools there is.
However i am unable to find out what GUI liberay to use. my first search indicated that WPF is the newest "lib" for creating microsoft UI many other threads gave an indication of that this might not be the case.
Therefore i am asking you guys what is the newest UI "lib" for C# and what would you advice me to use?
As pointed out by Giedrius, either Windows Forms or WPF.
Personally, i would start with Forms for a few weeks, get to know the environment, then move on to WPF and the lovely world of XAML.
WPF is the right technology if you are targeting users with good machines. It leverage the power of graphics card and supports vector graphics. You will get good development speed with the XAML system and much more
If you are looking for any third party controls you can evaluate Infrajistics or Telerik.But depends on your UI requirements.
In terms of newest technologies then WPF is certainly the one I'd recommend you learn, but there is quite a level of interoperability between WPF and WinForms, i.e. you can host WinForm controls in WPF and (I think) vice versa.
One thing to be aware of is that WPF is a completely different beast to winforms - you can still do the usual drag and drop, but for fancy stuff you need to be changing the XAML and that can take some getting your head around.
Edit - it's worth taking the effort to learn WPF though because once you have then you'll be producing rich interfaces with ease.
For anything prior to Windows 8 then the latest is WPF. As of Windows 8 you have Metro (name changed I know) but then you could still use your newly aquired XAML skills (picked up from WPF) or start getting into HTML 5 and CSS 3 which would also stand you in good stead for web-based applications.
Win Forms is older than WPF but still well loved / established and can be useful in places. Like most things, choose the right tool for the job.
There are two main flavors of GUI (not counting web): WPF and Windows Forms. WPF is much more recent and if you have no experience on Windows Forms, WPF may be recommended GUI alternative.
Now WPF may have several "flavours" - it is kind of different in abilities in desktop applications, silverlight applications and windows store applications, desktop applications having most of the features, other two has limited set, mostly because of performance and security reasons (for example you can't render UI to image in windows store applications, but in desktop applications you can).
WPF has better hardware acceleration support, has better binding and async/threading support, is much more flexible, many elements look may be changed very easily - which can't be done so easy in Windows Forms, like combo box - you can change color in Windows Forms very easily, but if you will need rounded edges, that will be hard one.
Also WPF can be used in MVVM pattern easily, which is quite a challenge in Windows Forms.
Windows Forms on the other hand is little bit easier to learn + plus it has very good third party components - like Telerik, Devexpress. Both vendors have components for WPF also, but they ain't as good as Windows Forms ones, mostly because they were designed using Windows Forms knowledge, which doesn't fit WPF.
I recommend you to learn html, css and js. As I know you can build Microsoft Windows 8 .net applications using these languages. Check here and also it would be useful if you'll decide to make web application, where all these languages are using also.
If you don't want to limit your self with Windows 8, than try WPF. Applications on WPF will be able to run on any machine with .net framework version you used for application.
GL
As others have pointed out, WPF is the way to go.
One thing that has not been mentioned is that, (since you have java experience) you can think of WPF versus other technologies (such as winforms) the same way you can think of JavaFX versus previous java UI technologies (such as Swing).
Actually, JavaFX seems like a really poor copy of WPF. the language used to define the UI is XML-based (like XAML is), it has (much poorer) support for DataBinding, and many other similarities.

What is new since Family.Show? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I am relatively new to WPF and have been looking at Family.Show. It looks like a great reference application, but it has not been updated since February 2009. When I am looking through this code, are there any outdated techniques in here or improvements in the platform that I should be aware of?
[Edit] I have gotten a number of responses about PRISM and MVVM. I can now see how this question was not clear. Family.Show is one of the few WPF applications that I think really looks like a nice WPF application. I would like to use it as a model, but am concerned that the XAML and controls that they use might have been replaced with newer elements. Would someone give me some guidance in this respect?
[Edit] I should mention that I have read WPF 4 almost in its entirety, but not having much experience actually writing WPF applications, it is not easy for me to spot old or outdated technologies in something like Family.Show.
On the WPF side of things, not much has changed since 2009.
There are still DataTemplates, Styles, Data binding etc. They are used just like they have been used back then.
In the current version of the .NET framework a few more controls are present out of the box, so you might find some user controls in that example that are no longer necessary. However, the existing controls haven't changed as far as I know.
However, that application doesn't make any use of MVVM, which I personally find a big drawback.
So, you can use the application as a means to study WPF, but you shouldn't adept its architecture style in your own applications.
I think Prism is a very good framework to build enterprise(bigger) applications but at first sight it could be a little difficult. If you are new to WPF but want to get to know the WPF and MVVM better, check http://caliburnmicro.codeplex.com/ or http://waf.codeplex.com/. (With them it is a little easer to understand the principles.) You can get the source too and it is a good documentation to both, so you can learn a lot.
I think it is important to be familiar with the MVVM principles as a WPF developer.
I can suggest to you to watch the following two video from MIX conferences too:
http://channel9.msdn.com/events/MIX/MIX10/EX14
http://channel9.msdn.com/events/MIX/MIX11/OPN03
I would have a look at prism - its a great way to build WPF apps.

I need examples of WPF controls without XAML [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I got a good book on WPF but I want some code examples of programming the system without using a alot of XAML markup. In particular I want a rundown of individual text controls and events.
So I want a website or a book, not a snotty comment :P
Please note: stay on the topic! I am not criticizing the system. Thanks.
I'm not really sure what you're asking for because XAML is simply a markup language.
If you take something like
<Button Name="MyButton" Content="Test" />
you're really saying
Button b = new Button();
b.Name = "MyButton";
b.Content = "Test";
I don't think there is any need to create a tutorial on how to make WPF controls through code-behind because the markup language does almost the exact same thing, and in most cases its really easy to convert what you see in the Markup language to code-behind.
And if you really want examples of how to create a specific control through code-behind, you can usually find plenty of code examples via Google.
Glen, unfortunately for you WPF is not built to be used through code. Though you may do some things through code, it's much harder to do so. WPF is built as data based, so to manipulate UI you need to manipulate data, not controls. It's a complicated subject, but lets say that controls may or may not exist in runtime based on their current visibility on screen and other properties.
If you still want to experiment with this you can check out controls in System.Windows.Controls namespace. Once you need to create ControlTemplate or DataTemplate you can use FrameworkElementFactory.
For example of how complicated this can be you can take a look at this question. For that reason, MS suggests that even when you need to manipulate WPF through code, you should place XAML in a string and load it using XamlReader.Load() method (this suggestion is in Remarks section of FrameworkElementFactory documentation).
This is one Where I started With WPFTutorials
If you really want to learn WPF "code-first", there's really just one primary resource out there that I'm aware of:
Sells' & Griffiths' Programming WPF book
They approach WPF from a code-first perspective. I don't think xaml is even introduced until the second half of the (rather large) book.
Note that you'll also be learning to do some things the "old" way, where the newer versions of WPF have learned lessons from Silverlight, etc. (E.g., Triggers vs VisualStateManager)
http://msdn.microsoft.com/en-us/library/ms754130.aspx
as Ed S. suggested, this is the MSDN entry about WPF. On the left, there's a link to controls. Each one control has a link about what they do, what they are for, etc.
I found this WPF/Winform comparison helpful as well:
http://msdn.microsoft.com/en-us/library/ms750559(v=VS.90).aspx
If you want to know something more about WPF, then you can have a look at this blog. You will find a lot of useful informtion about WPF.
Regards
Debasis

Learning WPF without success [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 9 years ago.
Hello developers and designers,
I am very willing to learn WPF in which i use C# as the logic code.
Or i 'try' to anyway.
I have written a 2-page long code-behind in Forms-style though, so i know some syntaxes.
But that was a really cumbersome way of doing it.
The problem is that i am still lingering around the area of understanding at least the basic concept of object oriented programming. But 9 out of 10 times i am not getting the example-codes entirely because of that '1 little thing of which i don't even know what it's called'.
How do you even know if there is a command for the function you want to express and more importantly.... how it's called and where it located in what namespace?
Even the best video-examples aren't doing it for me, because when any code is typed, they never explain how the code exactly works. And most of the times it just doesn't even add up to what i know of logic code (of course i'm wrong).
In the early days i learned the Commodore64's Basic no problem.
Learning and writing Actionscript (Flash), within 2 months creating a 2D-shoot'em up
Learning and writing CMD, within 3 months writing 5000+ lines of code for all sorts of functions.
Why in Merlin's beard is WPF so hard?
Watching the "simplest" tutorial-video's are becoming more and more de-motivational.
Anyone recognizes this?
Thanks for reading,
Danny
Regarding WPF the articles I've found to be most useful are the overviews on MSDN, they might take quite some time to work through but they are concise and in-depth, see this page for a master-overview.
Why WPF is hard is a good question, one primary cause might be that it is simply huge, at least i perceive it that way. Aside from having all the code you also now have XAML markup which is a world of its own.
Someone from Microsoft who did a presentation on F# in 2008 said that if you know three of the keywords, let, fun & |>, you know the whole language, which is not even that much of an overstatement. WPF on the other hand is not a language, it is a sub-framework. If F# can be likened to 3 nanotechnology building blocks then WPF is a 50 meter workbench stacked with tools (the controls) and a dozen heavy duty machines (WPF mechanisms like dependency properties, data binding, commanding, data templating, etc.), and all of those come with a manual. So if you are facing a problem you pretty much need to know what all the tools and machines do so you know which to use, and then of course you also need to know how to use them, apart from their basic functionality each may even have its own kinks and peculiarities which are important to keep in mind.
So learning WPF requires a lot of raw knowledge of the framework but also experience so you know what is the best approach in a given situation and to get a feeling for what can be done and what cannot.
MVVM: http://msdn.microsoft.com/en-us/magazine/dd419663.aspx
Learn it then use it.
I figured I'd add my $.02 since I've recently started using WPF. First off, you'll need to read that MVVM article mentioned by Fëanor, and DEAR GOD, download the sample code and learn what every line in that program does! Reading the article is great, but seeing the code, running it, changing it, etc, is INVALUABLE. I also echo the comments about the MSDN overviews, and the one about creating a side project rather than learning WPF via an existing project.
Other than that, don't expect to get WPF in a day, or even in a week. I've been using it for about a month now, and I've still got a ways to go. I had my "AHA!" moment about a week ago where everything started to click and it became apparent to me what I DIDN'T know which is important. A good strategy would be for you to pick a single concept such as Data Binding, or Data Templates, or Styles, and explore each in depth. It's a lot to chew on, so just remember that Rome wasn't built in a day. And if you're not already comfortable with data binding, I'd pick that up early on since it's pretty crucial.
Lastly, once you learn WPF, it's going to be REALLY hard to go back to using Windows Forms :)
Have Fun!
Q
I don't think that WPF is actually that hard. I think it's just that WPF definitely requires a slightly different way of thinking. You can tell that it was built with certain principles in mind (like MVVM, as another poster mentioned), and it's very different from most other frameworks. If you try to do it like you did Windows Forms or MFC or ASP.NET or whatever... you'll struggle. You need to be willing to change your mind on how things work.
Frankly, I think the only way to learn it is with experimentation. Come up with some side project to work on using WPF and try your hand at it. Learn a bit and refactor it. Get a good book, read the WPF disciples list, read anything that Sacha Barber writes, read the WPF section here on SO.
When you have your first "ah ha!" moment where you decide to write an Attached Property to solve some obscure problem you're having, you'll know you've finally understood it :)

What all should an expert C#/.Net/WPF developer know? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I have some 5+ years' background in C++/Unix development. I have been trying my hand at C#/.Net/WPF based software development for some time now. I am at a stage where I can write functioning applications fluently, but am not sure how to take my skills to the next level.
So, my question(s) to you all, especially to those who are experienced in C#/.Net/WPF:
What are the component skills and knowledge that an expert developer on this platform should have?
What technology-specific books would you expect a would-be expert to have read?
What other deliberate steps can I take to become really good at application development using C#/.Net/WPF?
Many thanks in advance! I would be especially grateful for comprehensive answers - I'm pretty sure many other developers have similar questions.
Learn how the C# language and .NET runtime work by reading CLR via C#.
Scott Hanselman's article, "What Great .NET Developers Ought To Know", is a great resource on the subject.
My team has worked in C# for the past 5 years. Typically, experienced C++ programmers take a week or two to become fully functional in C#. I've even seen some do it almost instantly, after sitting with them one morning, showing them our code, and explaning the basics of the language that differ from C++. But that's not how I recommend you do it.
I recommend you do this:
Read a C# book: My pick would be Programming C# by Jesse Liberty. Important chapters are the language itself and the basics of the .NET framework libraries. The .NET Framework is huge, so you don't have to know everything in detail. You can skip through (or skim) the Windows Forms chapters. Windows Forms is so different from WPF that it won't be useful to you if you are planning on only doing WPF.
(source: amazon.com)
Read a WPF book: The best book I read so far is Windows Presentation Foundation Unleashed by Adam Nathan. WPF has a steep learning curve compared to Windows Forms, even for experienced C#/WinForms programmers. It has a lot of complex elements to understand like XAML, dependency properties, bindings, templates, animation, resources, etc. This book teaches you the basics gradually and is easy to read and understand. And it's in full color!
Read about the Model-View-ViewModel pattern: I haven't found a good book on that yet, but it's been very important for me to make my WPF applications more simple and manageable. My favorite material to learn about MVVM is this one hour presentation by Jason Dolinger. He builds a WPF application from scratch using no particular pattern, and step by step, migrates it to the MVVM pattern.
Also have a look at this past Stackoverflow question: Questions every .NET developer should be able to answer.
For WPF specifically (and the power of WPF binding) I like M-V-VM: http://karlshifflett.wordpress.com/
Make sure you learn how to use and leverage Dependency Injection / Inversion of Control in your applications. Other very important pieces of software to learn to include with your development is Microsoft Enterprise Library and Windows Communication Foundation. Those 2 tools offer an amazing amount of leverage to avoid having to recreate the wheel to solve problems.
Other really good packages to become familiar with are NHibernate and Fluent NHibernate.
Windows Workflow Foundation is a very powerful piece of software however the complexity level is high this would be another great addition to your knowledge base time permitting.
I would add unit testing, TDD, and mocking frameworks to your list of things to know.
I have "The Art of Unit Testing" and found it helpful.
I really like WPF in Action and Programming .NET Components is essential reading for any .NET developer.

Categories