Search
Thursday, December 13, 2018 ..:: Home ::.. Register  Login
   Calendar  
     
  
   Search  
     
  
   Blogroll  
     
  
   Disclosure  
All blog entries are the opinions of the author and do not necessarily reflect the opinions of their employer. All the code presented is for explanation and demonstration purposes only. Any damages incurred to your site and/or data are not the responsibility of the author. Every effort is taken to ensure the code properly compiles, however sometimes there are some hiccups and you might be required to do your own debugging.
     
  
   TechTidBits (Blog)  

Why is XAML so long/confusing/verbose?

Apr 21

Written by:
Wednesday, April 21, 2010 9:07 PM  RssIcon

XAMLOk, what's the deal with XAML?  WTF is it so freak'n complicated?  Have you looked at those WPF XAML files lately?  Read on for a brief explanation.

XAMLIf you've started doing any WPF or Silverlight developing, you're familiar with XAML.  That's the XML file describing your user interface, your User eXperience, your UX.  Recently CM and SB have shown me when I'm in VS to type it out instead of dragging'n'dropping from the toolbox.  Why you ask?  Good question, cause where you "put" the user control is more exact when you're typing it out than when you're dropping it, DOH!  Also, VS' Intellisense makes the process shorter than you might be thinking.  PHEW!

If you've opened up an XAML file in Visual Studio, you might be a bit overwhelmed with the HUGE file staring back at you.  GULP!  And if it seems to get exponentially more complicated as you add just a few more user controls, you'd be right!  So what gives?  WTF is going on?

XAML in VS

Well, the deal here is, XAML IS exacting, unambigious and accurate.  Almost to a fault.  It suffers from the same problems as regular expressions.  You know, those regex strings you avoid until you absolutely HAVE to look at, and even then, you need to refresh your coffee cup cause you KNOW it's gonna be a long day.  Almost the same deal with XAML except with a bit of patience, you CAN indeed make heads and tails out of the Grids, StackPanels, LinearGradient, Buttons, etc.

Let's put it another way, VS no longer describes the UI in code and puts it ALL into the XAML.  Yes, technically, under the hood, VS compiles your XAML into IL which is your UI described in code, but it's not like the C#/VB.NET code you are used to seeing in WinForms.  XAML HAS to be verbose if it's to be exact, and unambigious.  It has to be that way cause it is in itself a computer language on it's own.

Put it another way, and this is being a bit harsher and borders on being rude but it's true.  If you're doing thick client development, it's something you'll HAVE to learn, so why not sooner than later.  Why "HAVE" to?  Cause WPF IS the next version of WinForms, which is being "dead-ended" as a "technology."  Sure, MS is going to have bug-fixes and the like.  But there is NO WAY Microsoft is going to update WinForms to have a LinearGradient user control or any of the other funky and cool user controls you get with WPF.  If you want those, well, you better start learning XAML.

Ok, that's a bit harsh eh?  Here's an olive branch.  MS has Expression Blend, that's their designer tool.  Basically it is the real cool and slide UI designer you can use to create your programs and only have to deal with XAML when you absolutely need to.  AND it lets you do animations and templates graphically.  VERY COOL.

I hope this eases a bit of your tension/frustrations when looking at some XAML.  Now it's time to grab a coffee and get coding!

Tags:
Categories:
Location: Blogs Parent Separator TechTidBits

Your name:
Gravatar Preview
Your email:
(Optional) Email used only to show Gravatar.
Your website:
Title:
Comment:
Add Comment   Cancel 
     
  
Copyright 1999-2012 by PCHenry.com   Terms Of Use  Privacy Statement