I suggest you ...

Make it easier!

XAML is very (very!) difficult to learn and use. It is largely undiscoverable (unlike the .NET framework) and often produces error messages that border on mystical. I know this stuff can be difficult and that everyone is trying hard but everytime I try to do anything "outside the box" in XAML it's tremendously difficult. Run of the mills stuff is pretty easy, but one foot outside the line and “wham!”. At my last employer I hand-coded (and code the generation of postscript) and I’ve done similarly with HTML, so I’m use to the idea of rendering and declarative syntax (I currently work heavily in XML). With XAML it’s as if you have to have the entire schema in your head just to get started. Recently I’ve been trying to use Expression Blend 3, I think it’s actually much harder than just typing in the XAML, but it does make creating (copying!) custom styles and templates easier. Let me give you an example of two things that I’m sure are possible now, but seem to me wildly difficult to figure out from scratch.
1) I’ve been working on an idea, where I want have a non-rectangular base window and supply my own decoration (min, max, close, icon, etc.). I started very simply, using Expression to create a window with a WindowStyle of “None” then I placed a Border as the contained control of the window. I set a CornerRadius on the border, then attempted to set the Background on the window to “Transparent”. The only way I could find to do this in Expression was to type in the text in the XAML. That in itself isn’t a huge deal, but it suggests that people who use Expression, won’t be needing anything transparent. I then wanted to change the border color based on whether or not the window has focus. I’m sure there is a way to do this and I’m sure it will literally take 20 hours to ferret it out. I could catch the event in c# and set the properties in a few minutes (were I not trying to learn the “XAML way”) … which makes it especially frustrating since I’d be using exactly the same framework as XAML.
2) Another task I was looking at is drawing an icon. Using an icon that is in a jpg is pretty darn easy. If however you draw an icon using a Path, it seems “impossible” to use this as a resource and apply RenderTransforms at the point of use (say like putting it on a button). I’m sure it’s possible, but it sure isn’t discoverable.
It is very difficult for a developer to do anything “interesting” with XAML without making a career of it. I don’t have the time to specialize in doing or learning nothing but XAML for a year (or three). You pretty much have to be willing to hand edit the XAML to do anything interesting, but having to copy large templates and styles to make simple changes makes understanding the XAML that much harder (large redundant declaration are what developers are trained to avoid). I’m really beginning to wonder if we need a different language where developers can express GUI relationships that will compile into XAML (BAML).

33 votes
Vote
Sign in
Check!
(thinking…)
Reset
or sign in with
  • facebook
  • google
    Password icon
    Signed in as (Sign out)
    You have left! (?) (thinking…)
    dweeberlyloom shared this idea  ·   ·  Admin →

    2 comments

    Sign in
    Check!
    (thinking…)
    Reset
    or sign in with
    • facebook
    • google
      Password icon
      Signed in as (Sign out)
      Submitting...
      • dweeberlyloom commented  · 

        Thanks for the vote and the info. I wasn't really trying to get those issues resolved here, I've used the WPF forum and it works quite well. I only wanted to provide an example of things that don't seem hard, yet seem so to me. I should have been more clear in my description. I think what might be useful for MS is to create a usability lab for WPF. Bring in programmers with different levels of WPF experience, assign them tasks to be completed in WPF (using Expressions, VS and notepad), then watch how they go about solving the problem. This would quickly show "problem areas". There are lots of things that just seem "odd" to me. For example the .NET framework uses an "event" model, while XAML uses "triggers". To be a bit more complicated there is a Trigger class/element and a EventTrigger class/element. I wonder why we have three names/objects serving the same conceptual purpose. The documentation suggests that EventTrigger is a lot like a Trigger:EnterActions without a Trigger:ExitActions (so I wonder why ExitActions isn’t just optional, or is it?). More complicated still, I can define a <Border.Triggers> section, but not a <Border.EventTriggers> section. It’s like trying to program Assembly on a processor with 5,000 instruction types, each with its own unique format. It is exceeding difficult to build up any intuition about the syntax. I don’t want to paint all of XAML with the same brush, in fact doing things like laying out controls on a grid are very easy and intuitive and I believe it lures me into a false expectation about how other areas of XAML should operation. I have to say I also agree with you about the various “mini-languages” that XAML uses such as the data binding language or the undocumented “pack” uri. (I almost opened a suggestion on mini-language docs and examples) Simple data binding is just that ‘simple’, name something and point to it in the binding. However, whenever you attempt to do something a bit more “real worldy” you start to wonder if you are really writing Lisp with the ‘()’ replaced with ‘{}’. All this stuff unrolls into the .NET framework classes, yet it often seems much easier to code directly in C#. I do like the path mini language, it’s documented and concise, but like other things there are places I would expect to be able to use it where I can’t (or can’t figure out how). Again I’m not seeking answers to specific issues or trying to “beat up” on the MS WPF team, I’m just trying to point out that WPF is unnecessarily difficult to learn and use. I think that the WPF team might be too insulated from the broader programming community and should consider backing up a bit to look at developer usability issues.

      • Eric Hill commented  · 

        To make something transparent in Blend, in the Properties panel, Brushes section, click the small square next to, say, Background, pick "Custom Expression" from the context menu, and for the expression, type "Transparent". Or, below that in the Brushes section, click on Solid Color Brush and set A to 0. I bet if you posted questions like this to the WPF MSDN forum, you'd be answers back pretty quickly.

        I'm going to throw 1 vote your way, because XAML (really WPF in general) is very challenging. Data Binding is hard, and getting your head wrapped around what type of data binding to use when is very challenging. Debugging data binding is nearly impossible, best I can tell.

        As for Blend, takes a while to master, but it is so worth the investment of time. I struggled with it until I found the Blend tutorial that walks through building an Outlook-like UI. That was a huge help.

      Feedback and Knowledge Base