Best way for programmers to edit XAML - wpf

I was wondering how programmers chose to edit XAML. Most of the programmers I speak to seem to edit the raw XML, but that seems nuts to me since it is such a natural thing for a more visual editor (of course you often have to get down to the raw code ultimately, but isn't there a better way to lay out a grid, or edit a template, or add non c# triggers or manage commands? The one that really set me off was editing a menu -- Visual Studio 1.0 had a better menu editor for C++ than the raw XAML editing experience.)
When I edit .aspx files I use a visual editor much of the time, and then for the raw stuff I get into the html code.
I am aware of Expression Blend, but that seems far more focused on artistic types and GUI experts rather than programmers.
Does anyone have recommendations for a better editor for XAML than VS? Especially so since VS seems to have real nasty problems with XAML editing too, like bugginess and poor performance?
Appreciate your helping this XAML newbie.

I must agree that Blend has the best XAML editor I've tried. While VS2010 has made some significant improvements over 2008, it's not at the same level as Blend, and still feels a little clunky and is prone to freaking-out.
A good option for doing quick and dirty XAML editing is Kaxaml, a small editor which can be thought of as NotePad for XAML. It's fast(er than VS), has syntax-highlighting, auto-completion and an in-editor preview. I find it quite useful to use alongside VS, although it is limited for serious work.

The Visual Studio 2008 visual editor for XAML is still fairly primitive as you've encountered. When it comes down to wanting a true visual editor for XAML files, Blend is your best bet.
Like you, I originally thought Blend was targeted more for designers, but after using it for awhile now, I've found that Blend is clearly the best tool to visually edit XAML files. And since Blend integrates with Visual Studio Team System, you are able to switch between Visual Studio and Blend fairly seamlessly.

I use Blend when I'm doing visual tweaking or setting up Storyboards. I'll sometimes use it when first laying out a window, as well, but I've found that it's often easier to just hand-code the XAML rather than relying on Blend to guess the layout I want. I use Visual Studio when I'm doing XAML editing by hand, as it has better Intellisense and automatic formatting than Blend. I never use the visual editor for WPF in VS.
Part of the challenge here is that XAML layout is much more sophisticated than WinForms, so simple drag and drop doesn't quite cut it anymore. Blend does a pretty good job of guessing what I want, but if I really want to clarify how the visuals should be laid out, it's easier to express by typing the XAML, now that I'm familiar with it.
My typical workflow:
Create the initial layout by entering XAML in Visual Studio for the Grids, StackPanels, DockPanels and what have you that will lay out the window or control. I may also drop in some of the other controls as well, if the layout is simple.
Open up Blend and use it to place smaller controls, edit control properties and create/associate any styles I need. If I need custom control or data templates, I'll create them from Blend and then repeat the VS/Blend process on those templates.
Go back to VS and edit the XAML to set up my designer data context and manually code the data bindings.
Use Blend to verify the look of the finished window or control with the designer data context, tweaking and styling as needed to polish the UI.
I go back and forth a lot, but I'm typically also approaching it from a different mindset with each tool. If I was working with a larger company, I suspect most of what I do in Blend would be handled by a graphical designer, which is I think the intention. I don't mind wearing both hats, though and I've become accustomed to using both tools, as needed.

Visual Studio 2008 isn't the tool to edit WPF window. It falls in error usually if you uses a complex xaml type or some advanced styles.
Visual Studio 2010 has added a lot of new features in editing and specially designer for binding and IntelliSense for xaml too.
Blend is true that is oriented for designers like Microsoft want to sell it but I find it more like the missing feature of the designer of VS.
Blend has an advanced editor for styles and animation and helps a lot to generate.
But Blend lacks terribly in editing raw XAML, it has no IntelliSense at all.
My choice is to use both VS 2010 and Blend specially for styles and animations.

Expression Builder is a good free tool

Related

Are there things you can do with Expression Blend that you can't do with regular WPF?

I know that Blend does make things easier. But does it have any extra libraries available to it that give it more functionality? Or that allow things that can’t be done with regular WPF through Visual Studio?
Thanks?
The important libraries like Interactivity are redistributable, otherwise you would have quite some problems making use of what you did with Blend. But as they are just libraries nothing stops you from using them without Blend. Blend is a tool to make things easier just like Visual Studio, you need neither to write an application.
The product of those tools is always code (and possibly binaries), so in that sense there is nothing that only Blend can do but that is beside the point.
In short, no: there's nothing that Blend can do that you can't do yourself. Blend is basically just producing Xaml markup, which you can always produce by hand in Notepad if you choose to (let alone Visual Studio).
However, there are a number of things that Blend as a UI is much better suited to creating/editing - foremost in my mind are animations, which have nice pretty timeline support in Blend versus hand-typing markup in the VS designer (at least in VS2010, I'm not sure about VS2012).
There are a couple of Xml namespaces that Blend will include in your markup for its own purposes (typically to make the designer behave better). If you're a hand-editor of Xaml these are an annoyance (IMO), but they're certainly available to you still if you wanted to use them.

Does Expression Blend and Visual Studio Render WPF Controls Differently

In my WPF App, I have designed the Form using Expression Blend. To my surprise, the rendering is quite different when I load the solution using Visual Studio 2008. What is even more surprising, when I run the application, the resulting UI is different from the rendering done by both VS and Blend. Though I have not provided by XAML code, but in general is this a known Issue?
This is most definitely a known issue. Visual Studio uses what's known as the Cider designer to render WPF code. It most definitely renders XAML differently from Blend. Cider in VS2008 is pretty terrible, but gets much better in 2010 (but is still pretty terrible compared to Blend). One of the main differences between Cider and Blend is that Cider will read the code behind file (*.xaml.cs) while Blend will completely ignore it. Another notable difference is that Cider doesn't really understand things like Visual States and Blend SDK Behaviors (especially when you mix the two) while Blend completely understands them.
If you're constructing your view classes where you set your DataContext in XAML and then provide design time data (using Blend or a view model locator), you'll find that there are very few differences between Blend and how something actually looks at runtime.

First dabble in WPF using VS2010 and Expression

I am looking at using WPF for the GUI side of an upcoming project.
I know I have a huge decision to make on WPF vs. Win forms, but before I can make that decision I want to have a play around with a few simple WPF programs.
I have read a few posts online that say Visual Studio (2008 at the time of the post) lacked somewhat in editing the XAML and they recommended using MS Expression?
Questions are:-
I have VS2010, Has this fixed the lacklustre XAML editing present in VS2008?
Which product in Expression studio is used instead to edit the XAML?
Is the idea that you build the code side of the WPF in VS and Build up the XAML in Expression the copy the generated XAML into VS?
Any suggestions/tips on combining Expression and VS2010 would be appreciated.
Kind Regards
Ash
VS2010 has a much better enviroment for supporting XAML compared to VS2008 (in VS2008 it really was not the greatest experience) - so it would be possible to play around with some basic projects straight in VS2010...
Expression Blend really shows it power when you get into animations and transitions etc (Expression Blend to me would be the starting space in the Expression suite once you had covered the basics in VS2010).
The approach I would take is to get basic exposure in a tool/ide you are used to like VS2010, and then go through some of the Blend examples/tutorials that are available off the Expression Website to then take it to the next level.
The things that got me sold on WPF/Silverlight were databinding, separation of concerns using the MVVM pattern and commanding... it just seemed easier than what I was achieving in the winforms arena and cleaner... but it took a while before I was sold on it just because I was used to the winforms way of things and was trying to do WPF but with a Winforms approach.
For basic projects you could build the code and XAML all directly in VS2010. In fact for someone learning XAML for the first time who comes from a code centric perspective, coding XAML directly in VS2010 might be beneficial so that you get used to the basic syntax before you work in a tool like Expression Blend where that can be hidden from the developer.
use VS2010, it has much better intellisense support for XAML (and better support for large solutions >50 projects).
also you dont copy over files between Expression blend and VS2010, both open the same solution work on the same solution (Blend now has support for source contorl as well), you can flip to show the C# in Blend and vice versa in VS2010

XAML editing options

I use Visual Studio 2010 for WPF development of desktop apps. I edit my XAML with the visual editor, often tweaking it manually. My code-behind is C#. I haven't had any particular problems with this arrangement.
What are the advantages of Expression Blend over Visual Studio for editing XAML? Why is Expression Blend so expensive (it's more expensive than I paid for Visual Studio!!) Are there other full-featured XAML editors which are cheaper? (I'm not talking about free ones like kaxaml - those are too limited)
Thanks in advance.
Expression Blend does not come stand alone any longer; it is part of Expression Studio which also provides SketchFlow, Design, and a couple of other tools.
Visual Studio is geared towards the development aspect while Expression Blend is geared towards the design aspect. Building animations and performing binding all within the UI of Expression Blend is possible; not forcing you to modify the XAML by hand. You can however modify the XAML directly within Blend as you can the C# code behind as well.
I typically use Blend to lay out the UI and then make use of Visual Studio for the code behind and tweaking of the XAML. Blend is definitely a nice tool to have within your tool belt and I would recommend you download the trial to get a better understanding on the offering.
I find that the main advantage of Blend is that the UI makes it very, very easy to create complex animations and transitions - really gorgeous user experience things - but you need to spend some time 'learning' Blend to do it. To write the XAML in Visual Studio to create the same effects would be much more difficult - Blend does it much quicker, and you can preview the results instantly. It's not easy (if it's even possible - I've honestly not tried the more demanding stuff) with Visual Studio.

Is knowing blend required?

Do you expect your WPF developers to know expression blend?
Any good resources for learning more about Blend?
[UPDATE] Does knowing blend make you more productive?
I found Blend a great way to ease into XAML. Many of the common things you want to do are easy in Blend, especially databinding. Databinding has no intellisense and I found doing things in Blend a great way of discovering how do write the databinding syntax.
I now find myself mostly editing raw XAML buy hand.
The areas where blend is really handy:
Customizing templates.
Animation
Breaking the UI down into user controls
As a WPF developer I surely see the benifit of knowing Expression Blend for many of my previous projects. This help me to jump start on creating Usercontrols and Custom controls very effectively. And if we do in the conventional way of writing XAML from the scratch, it is gonna take a very long time of your development.
And also for creating DataTemplate,ControlTemplate,Styles and ItemsPanelTemplate - it is just a click away in Expression blend.
So I highly recommend Expression blend for a WPF programmer
I typically work in both blend and Visual Studio (2005) side by side when doing WPF development. (Although, granted, I typically do both design and c# coding).
The benefits of using Blend is that certain tasks are extremely fast there - things like picking colors/brushes, creating animations and layout fixes such as tweaking margins/paddings.
Another usage is to instantly see how your hand written XAML will look like without actually starting the app.
Blend has a bad habit of producing some weird XAML so I always have to clean it up in the VS text editor afterwards. I still find it to be a net win to use blend though.
So, to answer your question: Is Blend required? no, not really. But it will make your life easier for certain tasks and thus make you more productive.
Things like animation and gradient color definitions can really only be done effectively in Blend. Blend is also often extremely useful for generating some non-trivial custom visual elements, just so that you can view the generated Xaml and import a CLEANER version into your production code. Unfortunately, the point-and-click nature of Blend disguises the fact that huge volumes of very messy Xaml is being generated under the hood, and you'll want to REFACTOR that Xaml before using it in your production source. Fortunately, learning Blend is not that hard. The best tutorial I ever found was called the "Fabrikam" tutorial. There may be updated versions available, but one version of that tutorial is still available at the link below.
http://blogs.msdn.com/expression/articles/516589.aspx
Realistically, very few dev. shops have access to qualified "interactive designers" (its not somethiing a company can just re-task one of its junior Mar-Com people to perform), which means, at most places, developers will need to learn some amount of Blend if marketing wants to add the kind of fancy visuals that provide alot of the justification for using WPF in the first place.
As a developer, after working intensively with WPF for several months, you will find yourself becoming totally comfortable editing Xaml directly and, unlike with Windows Forms, you'll rarely rely on features in the VStudio designer. Not only is direct editing MUCH faster than scrolling through property lists, but VStudio does not have point-and-click support for many of the features you will use in production WPF applications (they just got around to adding an "event" tab in SP#1). Blend has more support for many of these items (it can generate a DataTemplate, for instance), but I usually only jump into Blend to create a quick animation or other visual effect, cut and paste a carefully-refactored version of the markup into my "official" VStudio project source, and move on.
I think at least the designers should start using the Expression Suite.
The developers should be somewhat familiar with the tools but just enough to enable them to communicate better with the designers.
Since there are not so many good WPF tools, knowing Blend is a pretty useful skill. However I wouldn't consider it as requirement. The whole idea of WPF is to distribute work between coders and designers. IMO developer is not required to know Blend throughout, but basic skills are required to understand designer's needs.
Video training for expression blend:
Total Training Expression Blend
http://expression.microsoft.com/en-us/cc136536.aspx
http://windowsclient.net/learn/videos_wpf.aspx
I (as a developer, not designer, soo not designer) tried to start learning WPF through Blend. While I could get stuff working, looking back at what I produced makes me shiver.
Now that I know my way around WPF pretty good, I still use Blend and Design every now and then, but my work is based in XAML (not designer view in VS, mind you, but XAML). In other words,
I know how to clean it up now.
I'm still wondering how I can get my Adobe-Flash, -Photoshop, -Illustrator design guru to work with me in WPF.
It fully depends on what you want to do. To answer your second question, would you really want to try editing an animation storyboard outside of Blend? If you're working with the actual Visuals of the application, Blend is best suited for this. If you want to hack around with databinding, validation and other things where you must swap back and forth with code. Obviously its more sense to work on the XAML in Visual Studio.
Lynda.com has some cool expression blend training available online...
Getting Started with Expression Blend by Lee Brimelow
Developers don't need to know Expression at all.
What you do need to know is XAML and not hide behind some tool, which would be the worst thing you could do as a WPF developer. Your tool of choice is yours to decide on. I used to use the XML editor in Visual Studio.
The only persons who need to know Blend are the ones in charge of the visual aspect of your WPF application. They have to be able to understand how to skin your application with templates, but other than that, they can keep to Blend exclusively.
In general, I think it's more important to for developers to understand XAML, as Blend is just a view on top of it. XAMLPad may be more useful for learning XAML in the first instance.
More specifically to this question though, I think if developers are working alongside designers using Blend, it could be very useful to know at least the basics. As well as allowing better communication (as mentioned by #kokos), it will let the developer perform minor edits (such as alignment etc.) in the same environment, and also understand the limitations and boundaries of the tool with respect to the code generation.
Historically, designer tools have had a few quirks that developers have had to work around, such as re-coding HTML in FrontPage, or generating font tags instead of using styles or classes. I'm sure Blend wouldn't do such things, but it might generate XAML that the developer would prefer to restructure or slim down, so knowing which features generate which styles of code could be very hand for the developer.
Would you require your HTML developers to use DreamWeaver?
All good WPF coders should know XAML by hand and only use tools like Blend for quick mockups, for doing animations or tweening, or for doing complicated gradients, etc.
Coding XAML by hand is a requirement for good WPF developers - Blend is a tool, not a substitute for knowing XAML.
Brennon Williams new book should also be good!!!
(source: pearsoned-ema.com)

Resources